bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: RFC: [PATCH] maint: use xconcatenated_filename


From: Akim Demaille
Subject: Re: RFC: [PATCH] maint: use xconcatenated_filename
Date: Tue, 5 Jun 2012 18:06:10 +0200

Le 25 mai 2012 à 10:45, Akim Demaille a écrit :

> 
> Le 25 mai 2012 à 09:49, Paul Eggert a écrit :
> 
>> On 05/25/2012 12:42 AM, Akim Demaille wrote:
>>> you use mbschr to look for `/' in file names, whereas Bruno
>>> uses strchr.
>> 
>> strchr is better for POSIX-like systems, since the
>> kernel is coding-system agnostic.  So I'd go with strchr.
> 
> OK, thanks!  Actually I see also that you made efforts
> to leave a single slash, even if DIR ended with many.
> Is this aesthetics, or is there some semantical difference
> that might result?
> 
> I checked all the other uses of mbschr, and they all seem
> to be overkill.  They were introduced by:
> 
> +2011-05-01  Joel E. Denny  <address@hidden>
> +
> +       Pacify -DGNULIB_POSIXCHECK.
> +       * bootstrap.conf (gnulib_modules): Add all modules suggested by
> +       -DGNULIB_POSIXCHECK.
> +       * src/files.c (file_name_split)
> +       * src/getargs.c (getargs)
> +       * src/location.c (boundary_set_from_string)
> +       * src/output.c (token_definitions_output, output_skeleton)
> +       * src/parse-gram.y (prologue_declaration)
> +       * src/scan-gram.l (handle_syncline)
> +       * src/symtab.c (symbol_new): Use mbschr and mbsrchr instead of
> +       strchr and strrchr.  In the cases of command-line options, file
> +       names, and thus locations, functionality may be improved.  In the
> +       case of symbol names, there should be no functional difference as
> +       all characters are ASCII, so the intended benefit is just warning
> +       suppression.

Given the discussion that followed, I prefer to revert strchr,
even though I perfectly well understand what prompted Joel to
make the converse move.

I installed this.

From 84526bf3d156154d8372fff0d232dd4f347f2233 Mon Sep 17 00:00:00 2001
From: Akim Demaille <address@hidden>
Date: Tue, 5 Jun 2012 17:46:58 +0200
Subject: [PATCH] maint: don't use mbsr?chr.

Basically, revert ba60c39547a445dee3e07920931b4d7a81843868's move to
mbs* functions, which was prompted by -DGNULIB_POSIXCHECK.  See
<http://lists.gnu.org/archive/html/bison-patches/2012-05/msg00052.html>
and following.

* bootstrap.conf: No longer ask for them.
* src/files.c, src/getargs.c, src/location.c,
* src/parse-gram.c, src/parse-gram.y, src/scan-gram.l,
* src/symtab.c: s/mbs(r?chr)/str$1/g.
---
 bootstrap.conf   |    2 +-
 lib/.gitignore   |    2 --
 src/files.c      |    2 +-
 src/getargs.c    |    2 +-
 src/location.c   |    4 ++--
 src/parse-gram.c |    2 +-
 src/parse-gram.y |    2 +-
 src/scan-gram.l  |    4 ++--
 src/symtab.c     |    2 +-
 9 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/bootstrap.conf b/bootstrap.conf
index c014084..6cdb017 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -24,7 +24,7 @@ gnulib_modules='
   error extensions fdl fopen-safer gendocs getopt-gnu
   gettext git-version-gen gitlog-to-changelog
   gpl-3.0 hash inttypes isnan javacomp-script
-  javaexec-script ldexpl maintainer-makefile malloc-gnu mbschr mbsrchr
+  javaexec-script ldexpl maintainer-makefile malloc-gnu
   mbswidth obstack perror progname
   quote quotearg
   readme-release
diff --git a/lib/.gitignore b/lib/.gitignore
index 0b3bcc9..8e0e209 100644
--- a/lib/.gitignore
+++ b/lib/.gitignore
@@ -109,9 +109,7 @@
 /mbchar.c
 /mbchar.h
 /mbrtowc.c
-/mbschr.c
 /mbsinit.c
-/mbsrchr.c
 /mbswidth.c
 /mbswidth.h
 /mbuiter.h
diff --git a/src/files.c b/src/files.c
index 550e42e..b7000cf 100644
--- a/src/files.c
+++ b/src/files.c
@@ -207,7 +207,7 @@ file_name_split (const char *file_name,
   *base = last_component (file_name);
 
   /* Look for the extension, i.e., look for the last dot. */
-  *ext = mbsrchr (*base, '.');
+  *ext = strrchr (*base, '.');
   *tab = NULL;
 
   /* If there is an extension, check if there is a `.tab' part right
diff --git a/src/getargs.c b/src/getargs.c
index d7e1ad4..82e4e35 100644
--- a/src/getargs.c
+++ b/src/getargs.c
@@ -559,7 +559,7 @@ getargs (int argc, char *argv[])
       case 'F': /* -FNAME[=VALUE]. */
         {
           char* name = optarg;
-          char* value = mbschr (optarg, '=');
+          char* value = strchr (optarg, '=');
           if (value)
             *value++ = 0;
           muscle_percent_define_insert (name, command_line_location (),
diff --git a/src/location.c b/src/location.c
index 281a887..88887e9 100644
--- a/src/location.c
+++ b/src/location.c
@@ -143,11 +143,11 @@ boundary_set_from_string (boundary *bound, char *loc_str)
 {
   /* Must search in reverse since the file name field may
    * contain `.' or `:'.  */
-  char *delim = mbsrchr (loc_str, '.');
+  char *delim = strrchr (loc_str, '.');
   aver (delim);
   *delim = '\0';
   bound->column = atoi (delim+1);
-  delim = mbsrchr (loc_str, ':');
+  delim = strrchr (loc_str, ':');
   aver (delim);
   *delim = '\0';
   bound->line = atoi (delim+1);
diff --git a/src/parse-gram.c b/src/parse-gram.c
index 2cfebe4..8539085 100644
--- a/src/parse-gram.c
+++ b/src/parse-gram.c
@@ -2431,7 +2431,7 @@ yyreduce:
 #line 343 "src/parse-gram.y"
     {
       char const *skeleton_user = (yyvsp[0].chars);
-      if (mbschr (skeleton_user, '/'))
+      if (strchr (skeleton_user, '/'))
         {
           size_t dir_length = strlen (current_file);
           char *skeleton_build;
diff --git a/src/parse-gram.y b/src/parse-gram.y
index 74eb4ae..8e38519 100644
--- a/src/parse-gram.y
+++ b/src/parse-gram.y
@@ -342,7 +342,7 @@ prologue_declaration:
 | "%skeleton" STRING
     {
       char const *skeleton_user = $2;
-      if (mbschr (skeleton_user, '/'))
+      if (strchr (skeleton_user, '/'))
         {
           size_t dir_length = strlen (current_file);
           char *skeleton_build;
diff --git a/src/scan-gram.l b/src/scan-gram.l
index fa200d6..d375fc1 100644
--- a/src/scan-gram.l
+++ b/src/scan-gram.l
@@ -941,8 +941,8 @@ handle_syncline (char *args, location loc)
 {
   char *after_num;
   unsigned long int lineno = strtoul (args, &after_num, 10);
-  char *file = mbschr (after_num, '"') + 1;
-  *mbschr (file, '"') = '\0';
+  char *file = strchr (after_num, '"') + 1;
+  *strchr (file, '"') = '\0';
   if (INT_MAX <= lineno)
     {
       warn_at (loc, _("line number overflow"));
diff --git a/src/symtab.c b/src/symtab.c
index b3f9456..d25b936 100644
--- a/src/symtab.c
+++ b/src/symtab.c
@@ -67,7 +67,7 @@ symbol_new (uniqstr tag, location loc)
 
   /* If the tag is not a string (starts with a double quote), check
      that it is valid for Yacc. */
-  if (tag[0] != '\"' && tag[0] != '\'' && mbschr (tag, '-'))
+  if (tag[0] != '\"' && tag[0] != '\'' && strchr (tag, '-'))
     yacc_at (loc, _("POSIX Yacc forbids dashes in symbol names: %s"),
              tag);
 
-- 
1.7.10.2






reply via email to

[Prev in Thread] Current Thread [Next in Thread]