* [RFC] Pascal language: case insensitivity!
@ 2000-06-19 3:57 Pierre Muller
2000-06-19 9:12 ` Larry Smith
2000-06-19 9:53 ` Mark Kettenis
0 siblings, 2 replies; 5+ messages in thread
From: Pierre Muller @ 2000-06-19 3:57 UTC (permalink / raw)
To: gdb
I have code in my local source tree that allow GDB to cope with the
case insensitivity of pascal language (at least partially).
The diffs are at the bottom of this file.
The way I implemented is to define a new function
extern int re_iexec _RE_ARGS ((char *,int));
that does a case sensitive (normal) search if the second arg is zero
while the search becomes insensitive if the second arg is non zero
in practice the second arg is
(current_language.language == language_pascal)
for now, but there might be other case insensitive languages supported.
(I even don't know if Modula 2 is case sensitive or not).
Practically I added also
extern int create_case_insensitive_translate_buffer _RE_ARGS (());
extern int reset_translate_buffer _RE_ARGS (());
functions to create the translations.
I already talked a while ago about this and someone (can't remember who)
said that there is a much simpler way to get this result.
I would of course really like to know more about this possibility.
The diffs below are not a patch as such, I only append them to show
the amont of code that is involved in this feature,
which isn't that huge in fact.
By the way, gnu-regex still has PARAMS stuff in it !
is the _RE_ARGS macro still to be kept or should it be removed as
PARAMS ?
Index: gnu-regex.c
===================================================================
RCS file: /cvs/src/src/gdb/gnu-regex.c,v
retrieving revision 1.4
diff -c -r1.4 gnu-regex.c
*** gnu-regex.c 2000/05/31 21:26:47 1.4
--- gnu-regex.c 2000/06/19 10:34:44
***************
*** 5480,5485 ****
--- 5480,5486 ----
/* BSD has one and only one pattern buffer. */
static struct re_pattern_buffer re_comp_buf;
+ static RE_TRANSLATE_TYPE case_insensitive_buffer;
char *
#ifdef _LIBC
***************
*** 5538,5543 ****
--- 5539,5616 ----
const int len = strlen (s);
return
0 <= re_search (&re_comp_buf, s, len, 0, len, (struct re_registers *)
0);
+ }
+
+ /* allocates a unique translation buffer for insensitive search */
+ /* FIXME this buffer is never disposed */
+
+ int create_case_insensitive_translate_buffer ()
+ {
+ int i;
+ if (!case_insensitive_buffer)
+ {
+ case_insensitive_buffer = (RE_TRANSLATE_TYPE) malloc (CHAR_SET_SIZE
+ * sizeof (*(RE_TRANSLATE_TYPE)0));
+ if (case_insensitive_buffer == NULL)
+ return (int) REG_ESPACE;
+
+ /* Map uppercase characters to corresponding lowercase ones. */
+ for (i = 0; i < CHAR_SET_SIZE; i++)
+ case_insensitive_buffer[i] = ISLOWER (i) ? toupper (i) : i;
+ }
+
+ /* Use this for re_comp called after */
+ re_comp_buf.translate = case_insensitive_buffer;
+
+ return 0;
+ }
+
+ int reset_translate_buffer ()
+ {
+ int i;
+ if (case_insensitive_buffer)
+ free(case_insensitive_buffer);
+ /* Use this for re_comp called after */
+ re_comp_buf.translate = NULL;
+ return 0;
+ }
+
+ int
+ re_iexec (s,insensitive)
+ char *s;
+ int insensitive;
+ {
+ RE_TRANSLATE_TYPE store_translate;
+ struct re_pattern_buffer private_preg;
+ const int len = strlen (s);
+ int res;
+ if (insensitive)
+ {
+ unsigned i;
+ if (!case_insensitive_buffer)
+ {
+ int res = create_case_insensitive_translate_buffer();
+ if (res)
+ return res;
+ }
+ store_translate = re_comp_buf.translate;
+ re_comp_buf.translate = case_insensitive_buffer;
+
+ for (i = 0; i < len; i++)
+ if (ISLOWER(s[i]))
+ s[i] = toupper (s[i]);
+ }
+ else
+ {
+ store_translate = re_comp_buf.translate;
+ re_comp_buf.translate = case_insensitive_buffer;
+
+ }
+ res = re_search (&re_comp_buf, s, len, 0, len, (struct re_registers *) 0);
+
+ re_comp_buf.translate = store_translate;
+ return
+ 0 <= res;
}
#endif /* _REGEX_RE_COMP */
Index: gnu-regex.h
===================================================================
RCS file: /cvs/src/src/gdb/gnu-regex.h,v
retrieving revision 1.1.1.4
diff -c -r1.1.1.4 gnu-regex.h
*** gnu-regex.h 1999/10/12 04:37:21 1.1.1.4
--- gnu-regex.h 2000/06/19 10:34:45
***************
*** 536,543 ****
--- 536,547 ----
#ifdef _REGEX_RE_COMP
# ifndef _CRAY
/* 4.2 bsd compatibility. */
+ extern int create_case_insensitive_translate_buffer _RE_ARGS (());
+ extern int reset_translate_buffer _RE_ARGS (());
extern char *re_comp _RE_ARGS ((const char *));
extern int re_exec _RE_ARGS ((const char *));
+ extern int re_iexec _RE_ARGS ((char *,int));
+
# endif
#endif
Index: source.c
===================================================================
RCS file: /cvs/src/src/gdb/source.c,v
retrieving revision 1.3
diff -c -r1.3 source.c
*** source.c 2000/05/28 01:12:29 1.3
--- source.c 2000/06/19 10:34:52
*************
*** 1587,1593 ****
/* we now have a source line in buf, null terminate and match */
*p = 0;
! if (re_exec (buf) > 0)
{
/* Match! */
fclose (stream);
--- 1587,1593 ----
/* we now have a source line in buf, null terminate and match */
*p = 0;
! if (re_iexec (buf,(int) (current_language->la_language ==
language_pascal)) > 0)
{
/* Match! */
fclose (stream);
***************
*** 1697,1703 ****
/* We now have a source line in buf; null terminate and match. */
*p = 0;
! if (re_exec (buf) > 0)
{
/* Match! */
fclose (stream);
--- 1697,1703 ----
/* We now have a source line in buf; null terminate and match. */
*p = 0;
! if (re_iexec (buf,(int) (current_language->la_language ==
language_pascal)) > 0)
{
/* Match! */
fclose (stream);
Index: symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.8
diff -c -r1.8 symtab.c
*** symtab.c 2000/06/14 00:59:07 1.8
--- symtab.c 2000/06/19 10:35:10
***************
*** 3677,3682 ****
--- 3677,3690 ----
}
}
+ if (current_language->la_language == language_pascal)
+ {
+ create_case_insensitive_translate_buffer();
+ }
+ else
+ {
+ reset_translate_buffer();
+ }
if (0 != (val = re_comp (regexp)))
error ("Invalid regexp (%s): %s", val, regexp);
}
***************
Pierre Muller
Institut Charles Sadron
6,rue Boussingault
F 67083 STRASBOURG CEDEX (France)
mailto:muller@ics.u-strasbg.fr
Phone : (33)-3-88-41-40-07 Fax : (33)-3-88-41-40-99
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC] Pascal language: case insensitivity!
2000-06-19 3:57 [RFC] Pascal language: case insensitivity! Pierre Muller
@ 2000-06-19 9:12 ` Larry Smith
2000-06-19 9:53 ` Mark Kettenis
1 sibling, 0 replies; 5+ messages in thread
From: Larry Smith @ 2000-06-19 9:12 UTC (permalink / raw)
To: Pierre Muller; +Cc: gdb
Pierre Muller wrote:
> for now, but there might be other case insensitive languages supported.
> (I even don't know if Modula 2 is case sensitive or not).
Modula/2 IS case-sensitive, as is Oberon, Oberon/2 and
Component Pascal.
--
.-. .-. .---. .---. .-..-. | "Bill Gates is just a monocle
| |__ / | \| |-< | |-< > / | and a Persian Cat away from
`----'`-^-'`-'`-'`-'`-' `-' | being one of the bad guys in a
My opinions only. | James Bond movie." -- D Miller
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC] Pascal language: case insensitivity!
2000-06-19 3:57 [RFC] Pascal language: case insensitivity! Pierre Muller
2000-06-19 9:12 ` Larry Smith
@ 2000-06-19 9:53 ` Mark Kettenis
2000-06-19 13:25 ` muller
1 sibling, 1 reply; 5+ messages in thread
From: Mark Kettenis @ 2000-06-19 9:53 UTC (permalink / raw)
To: muller; +Cc: gdb
Date: Mon, 19 Jun 2000 12:51:56 +0200
From: Pierre Muller <muller@cerbere.u-strasbg.fr>
I already talked a while ago about this and someone (can't remember who)
said that there is a much simpler way to get this result.
I would of course really like to know more about this possibility.
It might have been me. I believe I suggested to change GDB to use the
POSIX entry points regcomp() and regexec() instead of the BSD
re_comp() and re_exec() functions. There is already a REG_ICASE flag
that's supposed to ignore case when matching. It's just that you
cannot use it with re_comp() and re_exec().
The GNU regex library is used by several GNU packages, and the master
version lives in the GNU C Library. The version in GDB shouldn't
diverge too much from the master version, and I'm pretty sure your
patch will be rejected by the maintainer of the GNU C Library.
Mark
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC] Pascal language: case insensitivity!
2000-06-19 9:53 ` Mark Kettenis
@ 2000-06-19 13:25 ` muller
2000-06-19 15:34 ` Mark Kettenis
0 siblings, 1 reply; 5+ messages in thread
From: muller @ 2000-06-19 13:25 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb
At 18:53 19/06/00 +0200, Mark Kettenis wrote:
> Date: Mon, 19 Jun 2000 12:51:56 +0200
> From: Pierre Muller <muller@cerbere.u-strasbg.fr>
>
> I already talked a while ago about this and someone (can't remember who)
> said that there is a much simpler way to get this result.
> I would of course really like to know more about this possibility.
>
>It might have been me. I believe I suggested to change GDB to use the
>POSIX entry points regcomp() and regexec() instead of the BSD
>re_comp() and re_exec() functions. There is already a REG_ICASE flag
>that's supposed to ignore case when matching. It's just that you
>cannot use it with re_comp() and re_exec().
>
>The GNU regex library is used by several GNU packages, and the master
>version lives in the GNU C Library. The version in GDB shouldn't
>diverge too much from the master version, and I'm pretty sure your
>patch will be rejected by the maintainer of the GNU C Library.
I don't really care about acceptation of this patch,
but I do care about GDB supporting case insensitivness for pascal language.
So there are two possibilities to consider at least:
- apply my patches only locally in GDB tree.
- use POSIX regex instead of GNU regex in GDB.
I really have no idea about the second issue,
but there might be several drawbacks,
there are probably build systems that don't have
a without POSIX library.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC] Pascal language: case insensitivity!
2000-06-19 13:25 ` muller
@ 2000-06-19 15:34 ` Mark Kettenis
0 siblings, 0 replies; 5+ messages in thread
From: Mark Kettenis @ 2000-06-19 15:34 UTC (permalink / raw)
To: muller; +Cc: gdb
From: muller@cerbere.u-strasbg.fr
Date: Mon, 19 Jun 2000 22:29:54 +0200
I don't really care about acceptation of this patch,
but I do care about GDB supporting case insensitivness for pascal language.
So there are two possibilities to consider at least:
- apply my patches only locally in GDB tree.
Adding local changes to gnu-regex.c should only be done as a last
resort since it increases the amount of work to be done when importing
a new copy of the master source.
- use POSIX regex instead of GNU regex in GDB.
I really have no idea about the second issue,
but there might be several drawbacks,
there are probably build systems that don't have
a without POSIX library.
The GNU regex library provides both POSIX and BSD regex entry points.
Right now GDB uses the BSD functions, but we can change it to use the
POSIX functions. Someone needs to for over all the regex function
invocations in GDB and convert them. Then we can simply add the
REG_ICASE flag when necessary.
Mark
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2000-06-19 15:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-06-19 3:57 [RFC] Pascal language: case insensitivity! Pierre Muller
2000-06-19 9:12 ` Larry Smith
2000-06-19 9:53 ` Mark Kettenis
2000-06-19 13:25 ` muller
2000-06-19 15:34 ` Mark Kettenis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).