aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--src/posixregex.c146
1 files changed, 49 insertions, 97 deletions
diff --git a/src/posixregex.c b/src/posixregex.c
index d43180f..93723b1 100644
--- a/src/posixregex.c
+++ b/src/posixregex.c
@@ -97,26 +97,6 @@
97 97
98/////////////////// 98///////////////////
99// // 99// //
100// i18l Support //
101// //
102///////////////////
103
104#ifdef HAVE_GETTEXT
105# include <gettext.h>
106# include <libintl.h>
107# define _(String) gettext (String)
108# define gettext_noop(String) String
109# define N_(String) gettext_noop (String)
110#else
111# define _(String) (String)
112# define N_(String) String
113# define textdomain(Domain)
114# define bindtextdomain(Package, Directory)
115#endif
116
117
118///////////////////
119// //
120// Definitions // 100// Definitions //
121// // 101// //
122/////////////////// 102///////////////////
@@ -248,10 +228,8 @@ int main(int argc, char * argv[])
248 case 'n': 228 case 'n':
249 if ((opt.reg_cflags & REG_EXTENDED)) 229 if ((opt.reg_cflags & REG_EXTENDED))
250 { 230 {
251 fprintf(stderr, _("%s: option `-n' requires option `-b'\n" 231 fprintf(stderr, "%s: option `-n' requires option `-b'\n", PROGRAM_NAME);
252 "Try `%s --help' for more information.\n" 232 fprintf(stderr, "Try `%s --help' for more information.\n", PROGRAM_NAME);
253 ), PROGRAM_NAME, PROGRAM_NAME
254 );
255 return(1); 233 return(1);
256 }; 234 };
257#ifdef REG_NOSPEC 235#ifdef REG_NOSPEC
@@ -277,13 +255,11 @@ int main(int argc, char * argv[])
277 opt.verbosity++; 255 opt.verbosity++;
278 break; 256 break;
279 case '?': 257 case '?':
280 fprintf(stderr, _("Try `%s --help' for more information.\n"), PROGRAM_NAME); 258 fprintf(stderr, "Try `%s --help' for more information.\n", PROGRAM_NAME);
281 return(1); 259 return(1);
282 default: 260 default:
283 fprintf(stderr, _("%s: unrecognized option `--%c'\n" 261 fprintf(stderr, "%s: unrecognized option `--%c'\n", PROGRAM_NAME, c);
284 "Try `%s --help' for more information.\n" 262 fprintf(stderr, "Try `%s --help' for more information.\n", PROGRAM_NAME);
285 ), PROGRAM_NAME, c, PROGRAM_NAME
286 );
287 return(1); 263 return(1);
288 }; 264 };
289 }; 265 };
@@ -310,10 +286,8 @@ int main(int argc, char * argv[])
310 opt.re_str = getenv("POSIXREGEX"); 286 opt.re_str = getenv("POSIXREGEX");
311 if (!(opt.re_str)) 287 if (!(opt.re_str))
312 { 288 {
313 fprintf(stderr, _("%s: missing required argument `-- r'\n" 289 fprintf(stderr, "%s: missing required argument `-- r'\n", PROGRAM_NAME);
314 "Try `%s --help' for more information.\n" 290 fprintf(stderr, "Try `%s --help' for more information.\n", PROGRAM_NAME);
315 ), PROGRAM_NAME, PROGRAM_NAME
316 );
317 return(1); 291 return(1);
318 }; 292 };
319 293
@@ -406,29 +380,23 @@ int main(int argc, char * argv[])
406/// displays POSIX regular expressions 380/// displays POSIX regular expressions
407void my_posixregex(void) 381void my_posixregex(void)
408{ 382{
409 // TRANSLATORS: The following strings provide a table of POSIX regular 383 printf("POSIX ASCII Description\n");
410 // expersion key words, key word values, and a description of the key 384 printf("[:alnum:] [A-Za-z0-9] Alphanumeric characters\n");
411 // word. The table is displayed if the program is passed --posixregex 385 printf("[:alpha:] [A-Za-z] Alphabetic characters\n");
412 // on the command line. 386 printf("[:blank:] [ \\t] Space and tab\n");
413 printf(_("POSIX ASCII Description\n" 387 printf("[:cntrl:] [\\x00-\\x1F\\x7F] Control characters\n");
414 "[:alnum:] [A-Za-z0-9] Alphanumeric characters\n" 388 printf("[:digit:] [0-9] Digits\n");
415 "[:alpha:] [A-Za-z] Alphabetic characters\n" 389 printf("[:graph:] [\\x21-\\x7E] Visible characters\n");
416 "[:blank:] [ \\t] Space and tab\n" 390 printf("[:lower:] [a-z] Lowercase letters\n");
417 "[:cntrl:] [\\x00-\\x1F\\x7F] Control characters\n" 391 printf("[:print:] [\\x20-\\x7E] Visible characters and spaces\n");
418 "[:digit:] [0-9] Digits\n" 392 printf("[:space:] [ \\t\\r\\n\\v\\f] Whitespace characters\n");
419 "[:graph:] [\\x21-\\x7E] Visible characters\n" 393 printf("[:upper:] [A-Z] Uppercase letters\n");
420 "[:lower:] [a-z] Lowercase letters\n" 394 printf("[:xdigit:] [A-Fa-f0-9] Hexadecimal digits\n");
421 "[:print:] [\\x20-\\x7E] Visible characters and spaces\n" 395 printf("[:punct:] [-!\"#$%%&'()*+,./:;<=>?@[\\]_`{|}~] Punctuation characters\n");
422 "[:space:] [ \\t\\r\\n\\v\\f] Whitespace characters\n" 396 printf("\n");
423 "[:upper:] [A-Z] Uppercase letters\n" 397 printf("Example Uses:\n");
424 "[:xdigit:] [A-Fa-f0-9] Hexadecimal digits\n" 398 printf(" posixregex -r '^([[:alpha:]]+)://(([[:alnum:]]+)(:([[:alnum:]]+)){0,1}@){0,1}([-.a-z]+)(:([[:digit:]]+))*/([-/[:alnum:]]*)(\\?(.*)){0,1}$' http://jdoe:password@www.foo.org:123/path/to/file?query_string\n");
425 "[:punct:] [-!\"#$%%&'()*+,./:;<=>?@[\\]_`{|}~] Punctuation characters\n" 399 printf(" posixregex -r '\\$([[:digit:]]+)\\.([[:digit:]]{2,2})' 'Your change is $7.45.'\n");
426 "\n"
427 "Example Uses:\n"
428 " posixregex -r '^([[:alpha:]]+)://(([[:alnum:]]+)(:([[:alnum:]]+)){0,1}@){0,1}([-.a-z]+)(:([[:digit:]]+))*/([-/[:alnum:]]*)(\\?(.*)){0,1}$' http://jdoe:password@www.foo.org:123/path/to/file?query_string\n"
429 " posixregex -r '\\$([[:digit:]]+)\\.([[:digit:]]{2,2})' 'Your change is $7.45.'\n"
430 )
431 );
432 return; 400 return;
433} 401}
434 402
@@ -436,29 +404,23 @@ void my_posixregex(void)
436/// displays usage 404/// displays usage
437void my_usage(void) 405void my_usage(void)
438{ 406{
439// TRANSLATORS: The following strings provide usage for command. These 407 printf("Usage: %s [OPTIONS] string1 string2 ... stringN\n", PROGRAM_NAME);
440 // strings are displayed if the program is passed `--help' on the command 408 printf(" -b use obsolete ``basic'' REs (REG_BASIC)\n");
441 // line. The two strings referenced are: PROGRAM_NAME, and 409 printf(" -h, --help print this help and exit\n");
442 // PACKAGE_BUGREPORT 410 printf(" -i ignore upper/lower case distinctions. (REG_ICASE)\n");
443 printf(_("Usage: %s [OPTIONS] string1 string2 ... stringN\n" 411 printf(" -l enable newline-sensitive matching (REG_NEWLINE)\n");
444 " -b use obsolete ``basic'' REs (REG_BASIC)\n" 412 printf(" -n turn off recoginition of special characters (REG_NOSPEC)\n");
445 " -h, --help print this help and exit\n" 413 printf(" -p, --posixregex print regular expression patterns\n");
446 " -i ignore upper/lower case distinctions. (REG_ICASE)\n" 414 printf(" -q, --quiet, --silent do not print messages\n");
447 " -l enable newline-sensitive matching (REG_NEWLINE)\n" 415 printf(" -r regex regular expression to use for testing strings\n");
448 " -n turn off recoginition of special characters (REG_NOSPEC)\n" 416 printf(" -s display sub string which matches entire regular expression\n");
449 " -p, --posixregex print regular expression patterns\n" 417 printf(" -v, --verbose print verbose messages\n");
450 " -q, --quiet, --silent do not print messages\n" 418 printf(" -V, --version print version number and exit\n");
451 " -r regex regular expression to use for testing strings\n" 419 printf("\n");
452 " -s display sub string which matches entire regular expression\n" 420 printf("Variables:\n");
453 " -v, --verbose print verbose messages\n" 421 printf(" POSIXREGEX default regular expression to use for testing strings\n");
454 " -V, --version print version number and exit\n" 422 printf("\n");
455 "\n" 423 printf("Report bugs to <%s>.\n", PACKAGE_BUGREPORT);
456 "Variables:\n"
457 " POSIXREGEX default regular expression to use for testing strings\n"
458 "\n"
459 "Report bugs to <%s>.\n"
460 ), PROGRAM_NAME, PACKAGE_BUGREPORT
461 );
462 return; 424 return;
463} 425}
464 426
@@ -466,12 +428,8 @@ void my_usage(void)
466/// display incompatible usage 428/// display incompatible usage
467void my_usage_incompatible(char x, char y) 429void my_usage_incompatible(char x, char y)
468{ 430{
469 fprintf(stderr, 431 fprintf(stderr, "%s: incompatible options `-%c' and `-%c'\n", PROGRAM_NAME, x, y);
470 _( 432 fprintf(stderr, "Try `%s --help' for more information.\n", PROGRAM_NAME);
471 "%s: incompatible options `-%c' and `-%c'\n"
472 "Try `%s --help' for more information.\n"
473 ), PROGRAM_NAME, x, y, PROGRAM_NAME
474 );
475 return; 433 return;
476} 434}
477 435
@@ -479,18 +437,12 @@ void my_usage_incompatible(char x, char y)
479/// displays version 437/// displays version
480void my_version(void) 438void my_version(void)
481{ 439{
482 // TRANSLATORS: The following strings provide version and copyright 440 printf("%s (%s) %s\n", PROGRAM_NAME, PACKAGE_NAME, PACKAGE_VERSION);
483 // information if the program is passed --version on the command line. 441 printf("Written by David M. Syzdek.\n");
484 // The three strings referenced are: PROGRAM_NAME, PACKAGE_NAME, 442 printf("\n");
485 // PACKAGE_VERSION. 443 printf("%s\n", PACKAGE_COPYRIGHT);
486 printf(_("%s (%s) %s\n" 444 printf("This is free software; see the source for copying conditions. There is NO\n");
487 "Written by David M. Syzdek.\n" 445 printf("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
488 "\n"
489 "%s\n"
490 "This is free software; see the source for copying conditions. There is NO\n"
491 "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
492 ), PROGRAM_NAME, PACKAGE_NAME, PACKAGE_VERSION, PACKAGE_COPYRIGHT
493 );
494 return; 446 return;
495} 447}
496 448