commit a1db68d1ae0e4fcc6a3e93322349a0eb4d25befc Author: Alexey Tourbin Date: Sun Oct 8 01:25:49 2006 +0400 implemented -u option to convert underscores in tag and branch names to dots This is like git-cvsimport -u, but arguably smarter: each dot is converted iff the previous character was a digit. diff --git a/gram.y b/gram.y index 2ef1e20..413228e 100644 --- a/gram.y +++ b/gram.y @@ -21,6 +21,20 @@ #include "cvs.h" void yyerror (char *msg); +extern int opt_convert_underscores; + +static char * +fixup_symbol(char *s) +{ + if (opt_convert_underscores) { + char *p = s; + while (*++p) + if (*p == '_' && isdigit(p[-1])) + *p = '.'; + } + return s; +} + %} %union { @@ -95,7 +109,7 @@ symbols : symbols symbol symbol : name COLON NUMBER { $$ = calloc (1, sizeof (cvs_symbol)); - $$->name = $1; + $$->name = fixup_symbol ($1); $$->number = $3; } ; diff --git a/parsecvs.c b/parsecvs.c index e15eede..bd256ed 100644 --- a/parsecvs.c +++ b/parsecvs.c @@ -694,6 +694,8 @@ static void load_status_next (void) #define OBJ_PACK_TIME 1024 +int opt_convert_underscores = 0; + int main (int argc, char **argv) { @@ -713,8 +715,9 @@ main (int argc, char **argv) static struct option options[] = { { "help", 0, 0, 'h' }, { "version", 0, 0, 'V' }, + { "convert-underscores", 0, 0, 'u' }, }; - int c = getopt_long(argc, argv, "+hV", options, NULL); + int c = getopt_long(argc, argv, "+hVu", options, NULL); if (c < 0) break; switch (c) { @@ -730,6 +733,9 @@ main (int argc, char **argv) "This is free software; see the source for copying conditions. There is NO\n" "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"); return 0; + case 'u': + opt_convert_underscores = 1; + break; default: /* error message already emitted */ fprintf(stderr, "Try `%s --help' for more information.\n", argv[0]); return 1;