ALT Linux Team development discussions
 help / color / mirror / Atom feed
From: Alexey Tourbin <at@altlinux.ru>
To: devel@lists.altlinux.org
Subject: [devel] Q: bison strdup
Date: Sun, 8 Oct 2006 02:00:49 +0400
Message-ID: <20061007220049.GA21784@localhost.localdomain> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 253 bytes --]

Специалисты по бизону!
Кто-нибудь знает, когда я хочу немного модифицировать $1, нужно strdup
делать или нет?  А то у меня после вот этого вот изменения SEGV стал
наблюдаться.  Если нужно делать strdup, как тогда в конце правильно
очистить память?

[-- Attachment #1.2: zshgiChuD --]
[-- Type: text/plain, Size: 2071 bytes --]

commit a1db68d1ae0e4fcc6a3e93322349a0eb4d25befc
Author: Alexey Tourbin <at@altlinux.ru>
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;

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

             reply	other threads:[~2006-10-07 22:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-07 22:00 Alexey Tourbin [this message]
2006-10-07 23:17 ` Alexey Tourbin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20061007220049.GA21784@localhost.localdomain \
    --to=at@altlinux.ru \
    --cc=devel@lists.altlinux.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

ALT Linux Team development discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \
		devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru
	public-inbox-index devel

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git