Mercurial > emacs
comparison lib-src/ebrowse.c @ 35591:92a64125d228
(matching_regexp_buffer, matching_regexp_end_buf):
New variables.
(matching_regexp): Use them instead of static variables in
function scope.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Fri, 26 Jan 2001 09:32:03 +0000 |
parents | a5db73d46825 |
children | 742df7c33f75 |
comparison
equal
deleted
inserted
replaced
35590:c6e87bfc63db | 35591:92a64125d228 |
---|---|
1947 } | 1947 } |
1948 } | 1948 } |
1949 } | 1949 } |
1950 | 1950 |
1951 | 1951 |
1952 /* Actually local to matching_regexp. These variables must be in | |
1953 global scope for the case that `static' get's defined away. */ | |
1954 | |
1955 static char *matching_regexp_buffer, *matching_regexp_end_buf; | |
1956 | |
1957 | |
1952 /* Value is the string from the start of the line to the current | 1958 /* Value is the string from the start of the line to the current |
1953 position in the input buffer, or maybe a bit more if that string is | 1959 position in the input buffer, or maybe a bit more if that string is |
1954 shorter than min_regexp. */ | 1960 shorter than min_regexp. */ |
1955 | 1961 |
1956 char * | 1962 char * |
1957 matching_regexp () | 1963 matching_regexp () |
1958 { | 1964 { |
1959 char *p; | 1965 char *p; |
1960 char *s; | 1966 char *s; |
1961 char *t; | 1967 char *t; |
1962 static char *buffer, *end_buf; | |
1963 | 1968 |
1964 if (!f_regexps) | 1969 if (!f_regexps) |
1965 return NULL; | 1970 return NULL; |
1966 | 1971 |
1967 if (buffer == NULL) | 1972 if (matching_regexp_buffer == NULL) |
1968 { | 1973 { |
1969 buffer = (char *) xmalloc (max_regexp); | 1974 matching_regexp_buffer = (char *) xmalloc (max_regexp); |
1970 end_buf = &buffer[max_regexp] - 1; | 1975 matching_regexp_end_buf = &matching_regexp_buffer[max_regexp] - 1; |
1971 } | 1976 } |
1972 | 1977 |
1973 /* Scan back to previous newline of buffer start. */ | 1978 /* Scan back to previous newline of buffer start. */ |
1974 for (p = in - 1; p > inbuffer && *p != '\n'; --p) | 1979 for (p = in - 1; p > inbuffer && *p != '\n'; --p) |
1975 ; | 1980 ; |
1987 } | 1992 } |
1988 | 1993 |
1989 /* Copy from end to make sure significant portions are included. | 1994 /* Copy from end to make sure significant portions are included. |
1990 This implies that in the browser a regular expressing of the form | 1995 This implies that in the browser a regular expressing of the form |
1991 `^.*{regexp}' has to be used. */ | 1996 `^.*{regexp}' has to be used. */ |
1992 for (s = end_buf - 1, t = in; s > buffer && t > p;) | 1997 for (s = matching_regexp_end_buf - 1, t = in; |
1998 s > matching_regexp_buffer && t > p;) | |
1993 { | 1999 { |
1994 *--s = *--t; | 2000 *--s = *--t; |
1995 | 2001 |
1996 if (*s == '"') | 2002 if (*s == '"') |
1997 *--s = '\\'; | 2003 *--s = '\\'; |
1998 } | 2004 } |
1999 | 2005 |
2000 *(end_buf - 1) = '\0'; | 2006 *(matching_regexp_end_buf - 1) = '\0'; |
2001 return xstrdup (s); | 2007 return xstrdup (s); |
2002 } | 2008 } |
2003 | 2009 |
2004 | 2010 |
2005 /* Return a printable representation of token T. */ | 2011 /* Return a printable representation of token T. */ |