@@ -380,11 +380,12 @@ int main(int argc, char *argv[]) {
380380 struct arg_int * base_count =
381381 arg_int0 (NULL , "base-count" , "<file>" , "Check and ensure base language has this many strings" );
382382 struct arg_int * str = arg_int0 ("s" , "string" , "<value>" , "display language string number" );
383+ struct arg_lit * strip = arg_lit0 (NULL , "strip" , "strip leading and trailing whitespace" );
383384 struct arg_file * output = arg_file0 ("o" , "output" , "<file>" , "compile output language file" );
384385 struct arg_int * check_count =
385386 arg_int0 ("c" , "check-count" , "<NUM>" , "Check that language file has this many entries, or bail." );
386387 struct arg_end * end = arg_end (20 );
387- void * argtable [] = {help , vers , file , input , base , base_count , output , str , check_count , end };
388+ void * argtable [] = {help , vers , file , input , base , base_count , strip , output , str , check_count , end };
388389 const char * progname = "languagetool" ;
389390
390391 bool language_is_utf8 = false;
@@ -432,10 +433,7 @@ int main(int argc, char *argv[]) {
432433 goto exit_0 ;
433434 }
434435
435- if (file -> count > 1 ) {
436- fprintf (stderr , "Too many input files provided! please supply one --file.\n" );
437- goto exit_0 ;
438- } else if (file -> count > 1 && input -> count > 1 ) {
436+ if (file -> count > 1 && input -> count > 1 ) {
439437 fprintf (stderr , "--import and --file arguments are incompatible.\n" );
440438 goto exit_0 ;
441439 } else if (file -> count + input -> count < 1 ) {
@@ -446,16 +444,10 @@ int main(int argc, char *argv[]) {
446444 if (base -> count > 0 && input -> count == 0 ) {
447445 fprintf (stderr , "Unexpected --base argument: it is meaningless without --import.\n" );
448446 goto exit_0 ;
449- } else if (base -> count > 1 ) {
450- fprintf (stderr , "Too many --base arguments: please supply only one.\n" );
451- goto exit_0 ;
452447 }
453448 if (base_count -> count > 0 && base -> count == 0 ) {
454449 fprintf (stderr , "Unexpected --base-count argument: it is meaningless without --base.\n" );
455450 goto exit_0 ;
456- } else if (base_count -> count > 1 ) {
457- fprintf (stderr , "Too many --base-count arguments: please supply only one.\n" );
458- goto exit_0 ;
459451 }
460452
461453 int ret ;
@@ -529,6 +521,16 @@ int main(int argc, char *argv[]) {
529521 goto exit_0 ;
530522 }
531523
524+ if (strip -> count ) {
525+ struct str s ;
526+ for (unsigned int id = 0 ; id < language .count ; id ++ ) {
527+ str_from_c (& s , language .strings [id ].data );
528+ str_strip (& s );
529+ memcpy (language .strings [id ].data , str_c (& s ), str_size (& s ) + 1 );
530+ str_free (& s );
531+ }
532+ }
533+
532534 // Print
533535 const sd_lang_string * ds ;
534536 if (str -> count > 0 ) {
0 commit comments