From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Sun, 8 Oct 2006 02:00:49 +0400 From: Alexey Tourbin To: devel@lists.altlinux.org Message-ID: <20061007220049.GA21784@localhost.localdomain> Mail-Followup-To: devel@lists.altlinux.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="+g7M9IMkV8truYOl" Content-Disposition: inline Subject: [devel] Q: bison strdup X-BeenThere: devel@lists.altlinux.org X-Mailman-Version: 2.1.9rc1 Precedence: list Reply-To: ALT Devel discussion list List-Id: ALT Devel discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Oct 2006 22:00:46 -0000 Archived-At: List-Archive: List-Post: --+g7M9IMkV8truYOl Content-Type: multipart/mixed; boundary="pf9I7BMVVzbSWLtt" Content-Disposition: inline --pf9I7BMVVzbSWLtt Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: quoted-printable =F3=D0=C5=C3=C9=C1=CC=C9=D3=D4=D9 =D0=CF =C2=C9=DA=CF=CE=D5! =EB=D4=CF-=CE=C9=C2=D5=C4=D8 =DA=CE=C1=C5=D4, =CB=CF=C7=C4=C1 =D1 =C8=CF=DE= =D5 =CE=C5=CD=CE=CF=C7=CF =CD=CF=C4=C9=C6=C9=C3=C9=D2=CF=D7=C1=D4=D8 $1, = =CE=D5=D6=CE=CF strdup =C4=C5=CC=C1=D4=D8 =C9=CC=C9 =CE=C5=D4? =E1 =D4=CF =D5 =CD=C5=CE=D1 =D0=CF= =D3=CC=C5 =D7=CF=D4 =DC=D4=CF=C7=CF =D7=CF=D4 =C9=DA=CD=C5=CE=C5=CE=C9=D1 S= EGV =D3=D4=C1=CC =CE=C1=C2=CC=C0=C4=C1=D4=D8=D3=D1. =E5=D3=CC=C9 =CE=D5=D6=CE=CF =C4=C5=CC= =C1=D4=D8 strdup, =CB=C1=CB =D4=CF=C7=C4=C1 =D7 =CB=CF=CE=C3=C5 =D0=D2=C1= =D7=C9=CC=D8=CE=CF =CF=DE=C9=D3=D4=C9=D4=D8 =D0=C1=CD=D1=D4=D8? --pf9I7BMVVzbSWLtt Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=zshgiChuD Content-Transfer-Encoding: quoted-printable 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 =20 This is like git-cvsimport -u, but arguably smarter: each dot is conver= ted 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" =20 void yyerror (char *msg); =20 +extern int opt_convert_underscores; + +static char * +fixup_symbol(char *s) +{ + if (opt_convert_underscores) { + char *p =3D s; + while (*++p) + if (*p =3D=3D '_' && isdigit(p[-1])) + *p =3D '.'; + } + return s; +} + %} =20 %union { @@ -95,7 +109,7 @@ symbols : symbols symbol symbol : name COLON NUMBER { $$ =3D calloc (1, sizeof (cvs_symbol)); - $$->name =3D $1; + $$->name =3D fixup_symbol ($1); $$->number =3D $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) =20 #define OBJ_PACK_TIME 1024 =20 +int opt_convert_underscores =3D 0; + int main (int argc, char **argv) { @@ -713,8 +715,9 @@ main (int argc, char **argv) static struct option options[] =3D { { "help", 0, 0, 'h' }, { "version", 0, 0, 'V' }, + { "convert-underscores", 0, 0, 'u' }, }; - int c =3D getopt_long(argc, argv, "+hV", options, NULL); + int c =3D 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 P= URPOSE.\n"); return 0; + case 'u': + opt_convert_underscores =3D 1; + break; default: /* error message already emitted */ fprintf(stderr, "Try `%s --help' for more information.\n", argv[0]); return 1; --pf9I7BMVVzbSWLtt-- --+g7M9IMkV8truYOl Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) iD8DBQFFKCORfBKgtDjnu0YRAvvyAKCvB6sYPG+WrBC9HQcj1+GuK5kvsQCgiahd 9g56Ouq9Thk3PI9AlBk0SKw= =2Dz6 -----END PGP SIGNATURE----- --+g7M9IMkV8truYOl--