diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/codetagger.c | 106 |
1 files changed, 35 insertions, 71 deletions
diff --git a/src/codetagger.c b/src/codetagger.c index ac724d0..90d9024 100644 --- a/src/codetagger.c +++ b/src/codetagger.c | |||
| @@ -78,26 +78,6 @@ | |||
| 78 | 78 | ||
| 79 | /////////////////// | 79 | /////////////////// |
| 80 | // // | 80 | // // |
| 81 | // i18l Support // | ||
| 82 | // // | ||
| 83 | /////////////////// | ||
| 84 | |||
| 85 | #ifdef HAVE_GETTEXT | ||
| 86 | # include <gettext.h> | ||
| 87 | # include <libintl.h> | ||
| 88 | # define _(String) gettext (String) | ||
| 89 | # define gettext_noop(String) String | ||
| 90 | # define N_(String) gettext_noop (String) | ||
| 91 | #else | ||
| 92 | # define _(String) (String) | ||
| 93 | # define N_(String) String | ||
| 94 | # define textdomain(Domain) | ||
| 95 | # define bindtextdomain(Package, Directory) | ||
| 96 | #endif | ||
| 97 | |||
| 98 | |||
| 99 | /////////////////// | ||
| 100 | // // | ||
| 101 | // Definitions // | 81 | // Definitions // |
| 102 | // // | 82 | // // |
| 103 | /////////////////// | 83 | /////////////////// |
| @@ -593,7 +573,7 @@ int codetagger_parse_tag_file(CodeTagger * cnf) | |||
| 593 | }; | 573 | }; |
| 594 | 574 | ||
| 595 | // loops through looking for tags | 575 | // loops through looking for tags |
| 596 | codetagger_verbose(cnf, _("indexing \"%s\"\n"), cnf->tagFile); | 576 | codetagger_verbose(cnf, "indexing \"%s\"\n", cnf->tagFile); |
| 597 | for(i = 0; i < (int)lineCount; i++) | 577 | for(i = 0; i < (int)lineCount; i++) |
| 598 | { | 578 | { |
| 599 | if (!(regexec(®ex, data[i], (size_t)5, match, 0))) | 579 | if (!(regexec(®ex, data[i], (size_t)5, match, 0))) |
| @@ -672,7 +652,7 @@ CodeTaggerData * codetagger_retrieve_tag_data(CodeTagger * cnf, const char * tag | |||
| 672 | if (!(strcasecmp(tagName, cnf->tagList[i]->name))) | 652 | if (!(strcasecmp(tagName, cnf->tagList[i]->name))) |
| 673 | return(cnf->tagList[i]); | 653 | return(cnf->tagList[i]); |
| 674 | 654 | ||
| 675 | codetagger_verbose(cnf, _(PROGRAM_NAME ": %s: %i: unknown tag \"%s\"\n"), fileName, lineNumber, tagName); | 655 | codetagger_verbose(cnf, PROGRAM_NAME ": %s: %i: unknown tag \"%s\"\n", fileName, lineNumber, tagName); |
| 676 | 656 | ||
| 677 | return(NULL); | 657 | return(NULL); |
| 678 | } | 658 | } |
| @@ -886,7 +866,7 @@ int codetagger_update_file(CodeTagger * cnf, const char * filename, | |||
| 886 | 866 | ||
| 887 | codetagger_debug(cnf); | 867 | codetagger_debug(cnf); |
| 888 | codetagger_debug_ext(cnf, filename); | 868 | codetagger_debug_ext(cnf, filename); |
| 889 | codetagger_verbose(cnf, _("processing \"%s\"\n"), filename); | 869 | codetagger_verbose(cnf, "processing \"%s\"\n", filename); |
| 890 | 870 | ||
| 891 | changed = 0; | 871 | changed = 0; |
| 892 | 872 | ||
| @@ -1029,29 +1009,23 @@ int codetagger_update_file(CodeTagger * cnf, const char * filename, | |||
| 1029 | /// displays usage | 1009 | /// displays usage |
| 1030 | void codetagger_usage(void) | 1010 | void codetagger_usage(void) |
| 1031 | { | 1011 | { |
| 1032 | // TRANSLATORS: The following strings provide usage for command. These | 1012 | printf("Usage: %s [OPTIONS] files\n", PROGRAM_NAME); |
| 1033 | // strings are displayed if the program is passed `--help' on the command | 1013 | printf(" -a include hidden files\n"); |
| 1034 | // line. The two strings referenced are: PROGRAM_NAME, and | 1014 | printf(" -c continue on error\n"); |
| 1035 | // PACKAGE_BUGREPORT | 1015 | printf(" -d enter debug mode\n"); |
| 1036 | printf(_("Usage: %s [OPTIONS] files\n" | 1016 | printf(" -f force writes\n"); |
| 1037 | " -a include hidden files\n" | 1017 | printf(" -h, --help print this help and exit\n"); |
| 1038 | " -c continue on error\n" | 1018 | printf(" -i file file containing tags\n"); |
| 1039 | " -d enter debug mode\n" | 1019 | printf(" -L follow symbolic links\n"); |
| 1040 | " -f force writes\n" | 1020 | printf(" -l str left enclosing string for tags\n"); |
| 1041 | " -h, --help print this help and exit\n" | 1021 | printf(" -q, --quiet, --silent do not print messages\n"); |
| 1042 | " -i file file containing tags\n" | 1022 | printf(" -r str right enclosing string for tags\n"); |
| 1043 | " -L follow symbolic links\n" | 1023 | printf(" -R recursively follow directories\n"); |
| 1044 | " -l str left enclosing string for tags\n" | 1024 | printf(" -t, --test show what would be done\n"); |
| 1045 | " -q, --quiet, --silent do not print messages\n" | 1025 | printf(" -v, --verbose print verbose messages\n"); |
| 1046 | " -r str right enclosing string for tags\n" | 1026 | printf(" -V, --version print version number and exit\n"); |
| 1047 | " -R recursively follow directories\n" | 1027 | printf("\n"); |
| 1048 | " -t, --test show what would be done\n" | 1028 | printf("Report bugs to <%s>.\n", PACKAGE_BUGREPORT); |
| 1049 | " -v, --verbose print verbose messages\n" | ||
| 1050 | " -V, --version print version number and exit\n" | ||
| 1051 | "\n" | ||
| 1052 | "Report bugs to <%s>.\n" | ||
| 1053 | ), PROGRAM_NAME, PACKAGE_BUGREPORT | ||
| 1054 | ); | ||
| 1055 | return; | 1029 | return; |
| 1056 | } | 1030 | } |
| 1057 | 1031 | ||
| @@ -1080,18 +1054,12 @@ void codetagger_verbose(CodeTagger * cnf, const char * fmt, ...) | |||
| 1080 | /// displays version information | 1054 | /// displays version information |
| 1081 | void codetagger_version(void) | 1055 | void codetagger_version(void) |
| 1082 | { | 1056 | { |
| 1083 | // TRANSLATORS: The following strings provide version and copyright | 1057 | printf("%s (%s) %s\n", PROGRAM_NAME, PACKAGE_NAME, PACKAGE_VERSION); |
| 1084 | // information if the program is passed --version on the command line. | 1058 | printf("Written by David M. Syzdek.\n"); |
| 1085 | // The three strings referenced are: PROGRAM_NAME, PACKAGE_NAME, | 1059 | printf("\n"); |
| 1086 | // PACKAGE_VERSION. | 1060 | printf("%s\n", PACKAGE_COPYRIGHT); |
| 1087 | printf(_("%s (%s) %s\n" | 1061 | printf("This is free software; see the source for copying conditions. There is NO\n"); |
| 1088 | "Written by David M. Syzdek.\n" | 1062 | printf("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"); |
| 1089 | "\n" | ||
| 1090 | "%s\n" | ||
| 1091 | "This is free software; see the source for copying conditions. There is NO\n" | ||
| 1092 | "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n" | ||
| 1093 | ), PROGRAM_NAME, PACKAGE_NAME, PACKAGE_VERSION, PACKAGE_COPYRIGHT | ||
| 1094 | ); | ||
| 1095 | return; | 1063 | return; |
| 1096 | } | 1064 | } |
| 1097 | 1065 | ||
| @@ -1137,7 +1105,7 @@ int codetagger_process_tag(CodeTagger * cnf, char * tagName, char ** data, size_ | |||
| 1137 | tagCount++; | 1105 | tagCount++; |
| 1138 | if (!(tag = (CodeTaggerData *) malloc(sizeof(CodeTaggerData)))) | 1106 | if (!(tag = (CodeTaggerData *) malloc(sizeof(CodeTaggerData)))) |
| 1139 | { | 1107 | { |
| 1140 | fprintf(stderr, _(PROGRAM_NAME ": out of virtual memory\n")); | 1108 | fprintf(stderr, "%s: out of virtual memory\n", PROGRAM_NAME); |
| 1141 | return(-1); | 1109 | return(-1); |
| 1142 | }; | 1110 | }; |
| 1143 | memset(tag, 0, sizeof(CodeTaggerData)); | 1111 | memset(tag, 0, sizeof(CodeTaggerData)); |
| @@ -1145,7 +1113,7 @@ int codetagger_process_tag(CodeTagger * cnf, char * tagName, char ** data, size_ | |||
| 1145 | // allocates memory for array | 1113 | // allocates memory for array |
| 1146 | if (!(ptr = realloc(cnf->tagList, sizeof(CodeTaggerData) * (tagCount + 1)))) | 1114 | if (!(ptr = realloc(cnf->tagList, sizeof(CodeTaggerData) * (tagCount + 1)))) |
| 1147 | { | 1115 | { |
| 1148 | fprintf(stderr, _(PROGRAM_NAME ": out of virtual memory\n")); | 1116 | fprintf(stderr, "%s: out of virtual memory\n", PROGRAM_NAME); |
| 1149 | codetagger_free_tag(cnf, tag); | 1117 | codetagger_free_tag(cnf, tag); |
| 1150 | return(-1); | 1118 | return(-1); |
| 1151 | }; | 1119 | }; |
| @@ -1156,7 +1124,7 @@ int codetagger_process_tag(CodeTagger * cnf, char * tagName, char ** data, size_ | |||
| 1156 | // saves tag name | 1124 | // saves tag name |
| 1157 | if (!(tag->name = strdup(tagName))) | 1125 | if (!(tag->name = strdup(tagName))) |
| 1158 | { | 1126 | { |
| 1159 | fprintf(stderr, _(PROGRAM_NAME ": out of virtual memory\n")); | 1127 | fprintf(stderr, "%s: out of virtual memory\n", PROGRAM_NAME); |
| 1160 | codetagger_free_tag(cnf, tag); | 1128 | codetagger_free_tag(cnf, tag); |
| 1161 | return(-1); | 1129 | return(-1); |
| 1162 | }; | 1130 | }; |
| @@ -1302,13 +1270,11 @@ int main(int argc, char * argv[]) | |||
| 1302 | cnf.opts &= cnf.opts & (~CODETAGGER_OPT_QUIET); | 1270 | cnf.opts &= cnf.opts & (~CODETAGGER_OPT_QUIET); |
| 1303 | break; | 1271 | break; |
| 1304 | case '?': | 1272 | case '?': |
| 1305 | fprintf(stderr, _("Try `%s --help' for more information.\n"), PROGRAM_NAME); | 1273 | fprintf(stderr, "Try `%s --help' for more information.\n", PROGRAM_NAME); |
| 1306 | return(1); | 1274 | return(1); |
| 1307 | default: | 1275 | default: |
| 1308 | fprintf(stderr, _("%s: unrecognized option `--%c'\n" | 1276 | fprintf(stderr, "%s: unrecognized option `--%c'\n", PROGRAM_NAME, c); |
| 1309 | "Try `%s --help' for more information.\n" | 1277 | fprintf(stderr, "Try `%s --help' for more information.\n", PROGRAM_NAME); |
| 1310 | ), PROGRAM_NAME, c, PROGRAM_NAME | ||
| 1311 | ); | ||
| 1312 | return(1); | 1278 | return(1); |
| 1313 | }; | 1279 | }; |
| 1314 | }; | 1280 | }; |
| @@ -1321,10 +1287,8 @@ int main(int argc, char * argv[]) | |||
| 1321 | }; | 1287 | }; |
| 1322 | if (!(cnf.tagFile )) | 1288 | if (!(cnf.tagFile )) |
| 1323 | { | 1289 | { |
| 1324 | fprintf(stderr, _("%s: missing required option `-f'\n" | 1290 | fprintf(stderr, "%s: missing required option `-f'\n", PROGRAM_NAME); |
| 1325 | "Try `%s --help' for more information.\n" | 1291 | fprintf(stderr, "Try `%s --help' for more information.\n", PROGRAM_NAME); |
| 1326 | ), PROGRAM_NAME, PROGRAM_NAME | ||
| 1327 | ); | ||
| 1328 | return(1); | 1292 | return(1); |
| 1329 | }; | 1293 | }; |
| 1330 | 1294 | ||
| @@ -1349,7 +1313,7 @@ int main(int argc, char * argv[]) | |||
| 1349 | 1313 | ||
| 1350 | if (!(cnf.tagCount)) | 1314 | if (!(cnf.tagCount)) |
| 1351 | { | 1315 | { |
| 1352 | fprintf(stderr, _(PROGRAM_NAME ": no tag definitions were found in \"%s\"\n"), cnf.tagFile); | 1316 | fprintf(stderr, "%s: no tag definitions were found in \"%s\"\n", PROGRAM_NAME, cnf.tagFile); |
| 1353 | return(1); | 1317 | return(1); |
| 1354 | }; | 1318 | }; |
| 1355 | 1319 | ||
