Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Kai Tietz <ktietz70@googlemail.com>
To: Binutils <binutils@sourceware.org>,
	gdb-patches@sourceware.org,
		GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [patch libiberty include]: Add additional helper functions for directory-separator searching
Date: Tue, 08 Mar 2011 16:52:00 -0000	[thread overview]
Message-ID: <AANLkTi=WZtnE5sQ8oVHYUJ2fqOD7bPvsv3rr2y7Or-1e@mail.gmail.com> (raw)
In-Reply-To: <AANLkTimyJb-3jEaWbbmUj2ZAOYPzhGT_GX9QFwR4DBCh@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 506 bytes --]

Hi,

I update the patch and put those new function into a separate file.

ChangeLog include/

2011-03-08  Kai Tietz

	* filenames.h (filename_dirchr): New prototype.
	(filename_dirrchr): Likewise.

ChangeLog libiberty/

2011-03-08  Kai Tietz

	* filename_chr.c: New file.
	* Makefile.in (CFILES): Add filename_chr.c file.
	(REQUIRED_OFILES): Add filename_chr.o
	(filename_chr.o): New rule.
	* functions.texi: Regenerated.

Tested for x86_64-pc-linux-gnu and x86_64-w64-mingw32. Ok for apply?

Regards,
Kai

[-- Attachment #2: libiberty_dirsep.txt --]
[-- Type: text/plain, Size: 6163 bytes --]

Index: gcc/include/filenames.h
===================================================================
--- gcc.orig/include/filenames.h	2011-02-28 19:16:35.000000000 +0100
+++ gcc/include/filenames.h	2011-03-08 11:11:10.909109700 +0100
@@ -75,6 +75,8 @@ extern int filename_cmp (const char *s1,
 
 extern int filename_ncmp (const char *s1, const char *s2,
 			  size_t n);
+extern char *filename_dirchr (const char *p);
+extern char *filename_dirrchr (const char *p);
 
 #ifdef __cplusplus
 }
Index: gcc/libiberty/functions.texi
===================================================================
--- gcc.orig/libiberty/functions.texi	2011-02-28 19:16:35.000000000 +0100
+++ gcc/libiberty/functions.texi	2011-03-08 16:02:12.147905400 +0100
@@ -296,6 +296,30 @@ and backward slashes are equal.
 
 @end deftypefn
 
+@c filename_chr.c:32
+@deftypefn Extension int filename_dirchr (const char *@var{p})
+
+The returned value is similar to what @code{strchr} would return for
+searching for a directory separator.
+
+This function does not normalize file name.  However, it does handle
+the fact that on DOS-like file systems, forward and backward slashes
+are directory separators.
+
+@end deftypefn
+
+@c filename_chr.c:65
+@deftypefn Extension int filename_dirrchr (const char *@var{p})
+
+The returned value is similar to what @code{strrchr} would return for
+searching for a directory separator.
+
+This function does not normalize file name.  However, it does handle
+the fact that on DOS-like file systems, forward and backward slashes
+are directory separators.
+
+@end deftypefn
+
 @c filename_cmp.c:81
 @deftypefn Extension int filename_ncmp (const char *@var{s1}, const char *@var{s2}, size_t @var{n})
 
Index: gcc/libiberty/Makefile.in
===================================================================
--- gcc.orig/libiberty/Makefile.in	2010-11-21 14:28:05.000000000 +0100
+++ gcc/libiberty/Makefile.in	2011-03-08 16:01:09.254418900 +0100
@@ -127,8 +127,8 @@ CFILES = alloca.c argv.c asprintf.c atex
 	calloc.c choose-temp.c clock.c concat.c cp-demangle.c		\
 	 cp-demint.c cplus-dem.c crc32.c				\
 	dyn-string.c							\
-	fdmatch.c ffs.c fibheap.c filename_cmp.c floatformat.c		\
-	fnmatch.c fopen_unlocked.c					\
+	fdmatch.c ffs.c fibheap.c filename_cmp.c filename_chr.c		\
+	floatformat.c fnmatch.c fopen_unlocked.c			\
 	getcwd.c getopt.c getopt1.c getpagesize.c getpwd.c getruntime.c	\
          gettimeofday.c                                                 \
 	hashtab.c hex.c							\
@@ -168,7 +168,8 @@ REQUIRED_OFILES =							\
 	./choose-temp.$(objext) ./concat.$(objext)			\
 	./cp-demint.$(objext) ./crc32.$(objext) ./dyn-string.$(objext)	\
 	./fdmatch.$(objext) ./fibheap.$(objext)				\
-	./filename_cmp.$(objext) ./floatformat.$(objext)		\
+	./filename_cmp.$(objext) ./filename_chr.$(objext)		\
+	./floatformat.$(objext)						\
 	./fnmatch.$(objext) ./fopen_unlocked.$(objext)			\
 	./getopt.$(objext) ./getopt1.$(objext) ./getpwd.$(objext)	\
 	./getruntime.$(objext) ./hashtab.$(objext) ./hex.$(objext)	\
@@ -653,6 +654,13 @@ $(CONFIGURED_OFILES): stamp-picdir
 	else true; fi
 	$(COMPILE.c) $(srcdir)/filename_cmp.c $(OUTPUT_OPTION)
 
+./filename_chr.$(objext): $(srcdir)/filename_chr.c config.h $(INCDIR)/filenames.h \
+	$(INCDIR)/safe-ctype.h
+	if [ x"$(PICFLAG)" != x ]; then \
+	  $(COMPILE.c) $(PICFLAG) $(srcdir)/filename_chr.c -o pic/$@; \
+	else true; fi
+	$(COMPILE.c) $(srcdir)/filename_chr.c $(OUTPUT_OPTION)
+
 ./floatformat.$(objext): $(srcdir)/floatformat.c config.h $(INCDIR)/ansidecl.h \
 	$(INCDIR)/floatformat.h $(INCDIR)/libiberty.h
 	if [ x"$(PICFLAG)" != x ]; then \
Index: gcc/libiberty/filename_chr.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ gcc/libiberty/filename_chr.c	2011-03-08 15:55:30.844446300 +0100
@@ -0,0 +1,95 @@
+/* File name comparison routine.
+
+   Copyright (C) 2011 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#include "filenames.h"
+#include "safe-ctype.h"
+
+/*
+
+@deftypefn Extension int filename_dirchr (const char *@var{p})
+
+The returned value is similar to what @code{strchr} would return for
+searching for a directory separator.
+
+This function does not normalize file name.  However, it does handle
+the fact that on DOS-like file systems, forward and backward slashes
+are directory separators.
+
+@end deftypefn
+
+*/
+
+char *
+filename_dirchr (const char *p)
+{
+  char *r;
+#ifdef HAVE_DOS_BASED_FILE_SYSTEM
+  char *r2;
+#endif
+  if (!p)
+    return NULL;
+  r = strchr (p, '/');
+#ifdef HAVE_DOS_BASED_FILE_SYSTEM
+  r2 = strchr (p, '\\');
+  if (!r || (r2 && r2 < r))
+    r = r2;
+#endif
+  return r;
+}
+
+/*
+
+@deftypefn Extension int filename_dirrchr (const char *@var{p})
+
+The returned value is similar to what @code{strrchr} would return for
+searching for a directory separator.
+
+This function does not normalize file name.  However, it does handle
+the fact that on DOS-like file systems, forward and backward slashes
+are directory separators.
+
+@end deftypefn
+
+*/
+
+char *
+filename_dirrchr (const char *p)
+{
+  char *r;
+#ifdef HAVE_DOS_BASED_FILE_SYSTEM
+  char *r2;
+#endif
+
+  if (!p)
+    return NULL;
+  r = strrchr (p, '/');
+#ifdef HAVE_DOS_BASED_FILE_SYSTEM
+  r2 = strrchr (p, '\\');
+  if (!r || (r2 && r2 > r))
+    r = r2;
+#endif
+  return r;
+}

  parent reply	other threads:[~2011-03-08 15:11 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-08 11:25 Kai Tietz
2011-03-08 11:53 ` Eli Zaretskii
2011-03-08 11:55   ` Kai Tietz
2011-03-08 12:01     ` Eli Zaretskii
2011-03-08 12:48       ` Kai Tietz
2011-03-08 13:25         ` Pedro Alves
2011-03-08 13:33           ` Kai Tietz
2011-03-08 14:30             ` Pedro Alves
2011-03-08 14:45               ` Kai Tietz
2011-03-08 18:49               ` Eli Zaretskii
2011-03-08 18:54                 ` Pedro Alves
2011-03-08 18:58                 ` Kai Tietz
2011-03-08 19:59                   ` Eli Zaretskii
     [not found] ` <E1Pwupb-0001ns-M8__47566.5626036518$1299582745$gmane$org@fencepost.gnu.org>
2011-03-08 12:43   ` Andreas Schwab
2011-03-08 16:52 ` Kai Tietz [this message]
2011-03-08 17:02   ` Kai Tietz
2011-03-08 18:39     ` Eli Zaretskii
2011-03-08 19:51       ` DJ Delorie
2011-03-08 22:38         ` Eli Zaretskii
2011-03-08 23:10         ` Pedro Alves
2011-03-09  7:12           ` Eli Zaretskii
2011-03-09 12:40             ` Pedro Alves
2011-03-09 12:54               ` Eli Zaretskii
2011-03-09 13:39                 ` Pedro Alves
2011-03-09 13:54                   ` Eli Zaretskii
2011-03-12 22:59                     ` Kai Tietz
2011-03-09 15:02                   ` Build regression [Re: [patch libiberty include]: Add additional helper functions for directory-separator searching] Jan Kratochvil
2011-03-09 15:40                     ` Pedro Alves
2011-03-09 16:09                       ` Jan Kratochvil
2011-03-13  1:09         ` [patch libiberty include]: Add additional helper functions for directory-separator searching Kai Tietz

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='AANLkTi=WZtnE5sQ8oVHYUJ2fqOD7bPvsv3rr2y7Or-1e@mail.gmail.com' \
    --to=ktietz70@googlemail.com \
    --cc=binutils@sourceware.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=gdb-patches@sourceware.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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox