diff options
| author | Paul Eggert | 2015-05-24 14:20:10 -0700 |
|---|---|---|
| committer | Paul Eggert | 2015-05-24 14:20:10 -0700 |
| commit | 675c90a3b4c469e2e54e513b6f427ba4ec285ef5 (patch) | |
| tree | ed472149040ae75932156945beaccfe3ce3795c6 /lib-src | |
| parent | 379d77dfa3a03083517114e1ce32bb72137aea05 (diff) | |
| download | emacs-675c90a3b4c469e2e54e513b6f427ba4ec285ef5.tar.gz emacs-675c90a3b4c469e2e54e513b6f427ba4ec285ef5.zip | |
Simpilify etags TEX mode scanning
* lib-src/etags.c (TEX_mode, TEX_esc, TEX_opgrp, TEX_clgrp):
Remove static vars.
(TeX_commands): Deduce escapes here instead.
(TEX_LESC, TEX_SESC, TEX_mode): Remove; all uses removed.
This removes the need for a reset_input call.
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/etags.c | 74 |
1 files changed, 29 insertions, 45 deletions
diff --git a/lib-src/etags.c b/lib-src/etags.c index 48d2299410a..301dd3d8c0c 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c | |||
| @@ -4951,13 +4951,8 @@ static const char *TEX_defenv = "\ | |||
| 4951 | :part:appendix:entry:index:def\ | 4951 | :part:appendix:entry:index:def\ |
| 4952 | :newcommand:renewcommand:newenvironment:renewenvironment"; | 4952 | :newcommand:renewcommand:newenvironment:renewenvironment"; |
| 4953 | 4953 | ||
| 4954 | static void TEX_mode (FILE *); | ||
| 4955 | static void TEX_decode_env (const char *, const char *); | 4954 | static void TEX_decode_env (const char *, const char *); |
| 4956 | 4955 | ||
| 4957 | static char TEX_esc = '\\'; | ||
| 4958 | static char TEX_opgrp = '{'; | ||
| 4959 | static char TEX_clgrp = '}'; | ||
| 4960 | |||
| 4961 | /* | 4956 | /* |
| 4962 | * TeX/LaTeX scanning loop. | 4957 | * TeX/LaTeX scanning loop. |
| 4963 | */ | 4958 | */ |
| @@ -4967,8 +4962,8 @@ TeX_commands (FILE *inf) | |||
| 4967 | char *cp; | 4962 | char *cp; |
| 4968 | linebuffer *key; | 4963 | linebuffer *key; |
| 4969 | 4964 | ||
| 4970 | /* Select either \ or ! as escape character. */ | 4965 | char TEX_esc = '\0'; |
| 4971 | TEX_mode (inf); | 4966 | char TEX_opgrp, TEX_clgrp; |
| 4972 | 4967 | ||
| 4973 | /* Initialize token table once from environment. */ | 4968 | /* Initialize token table once from environment. */ |
| 4974 | if (TEX_toktab == NULL) | 4969 | if (TEX_toktab == NULL) |
| @@ -4980,9 +4975,33 @@ TeX_commands (FILE *inf) | |||
| 4980 | for (;;) | 4975 | for (;;) |
| 4981 | { | 4976 | { |
| 4982 | /* Look for a TEX escape. */ | 4977 | /* Look for a TEX escape. */ |
| 4983 | while (*cp++ != TEX_esc) | 4978 | while (true) |
| 4984 | if (cp[-1] == '\0' || cp[-1] == '%') | 4979 | { |
| 4985 | goto tex_next_line; | 4980 | char c = *cp++; |
| 4981 | if (c == '\0' || c == '%') | ||
| 4982 | goto tex_next_line; | ||
| 4983 | |||
| 4984 | /* Select either \ or ! as escape character, whichever comes | ||
| 4985 | first outside a comment. */ | ||
| 4986 | if (!TEX_esc) | ||
| 4987 | switch (c) | ||
| 4988 | { | ||
| 4989 | case '\\': | ||
| 4990 | TEX_esc = c; | ||
| 4991 | TEX_opgrp = '{'; | ||
| 4992 | TEX_clgrp = '}'; | ||
| 4993 | break; | ||
| 4994 | |||
| 4995 | case '!': | ||
| 4996 | TEX_esc = c; | ||
| 4997 | TEX_opgrp = '<'; | ||
| 4998 | TEX_clgrp = '>'; | ||
| 4999 | break; | ||
| 5000 | } | ||
| 5001 | |||
| 5002 | if (c == TEX_esc) | ||
| 5003 | break; | ||
| 5004 | } | ||
| 4986 | 5005 | ||
| 4987 | for (key = TEX_toktab; key->buffer != NULL; key++) | 5006 | for (key = TEX_toktab; key->buffer != NULL; key++) |
| 4988 | if (strneq (cp, key->buffer, key->len)) | 5007 | if (strneq (cp, key->buffer, key->len)) |
| @@ -5020,41 +5039,6 @@ TeX_commands (FILE *inf) | |||
| 5020 | } | 5039 | } |
| 5021 | } | 5040 | } |
| 5022 | 5041 | ||
| 5023 | #define TEX_LESC '\\' | ||
| 5024 | #define TEX_SESC '!' | ||
| 5025 | |||
| 5026 | /* Figure out whether TeX's escapechar is '\\' or '!' and set grouping | ||
| 5027 | chars accordingly. */ | ||
| 5028 | static void | ||
| 5029 | TEX_mode (FILE *inf) | ||
| 5030 | { | ||
| 5031 | int c; | ||
| 5032 | |||
| 5033 | while ((c = getc (inf)) != EOF) | ||
| 5034 | { | ||
| 5035 | /* Skip to next line if we hit the TeX comment char. */ | ||
| 5036 | if (c == '%') | ||
| 5037 | while (c != '\n' && c != EOF) | ||
| 5038 | c = getc (inf); | ||
| 5039 | else if (c == TEX_LESC || c == TEX_SESC ) | ||
| 5040 | break; | ||
| 5041 | } | ||
| 5042 | |||
| 5043 | if (c == TEX_LESC) | ||
| 5044 | { | ||
| 5045 | TEX_esc = TEX_LESC; | ||
| 5046 | TEX_opgrp = '{'; | ||
| 5047 | TEX_clgrp = '}'; | ||
| 5048 | } | ||
| 5049 | else | ||
| 5050 | { | ||
| 5051 | TEX_esc = TEX_SESC; | ||
| 5052 | TEX_opgrp = '<'; | ||
| 5053 | TEX_clgrp = '>'; | ||
| 5054 | } | ||
| 5055 | reset_input (inf); | ||
| 5056 | } | ||
| 5057 | |||
| 5058 | /* Read environment and prepend it to the default string. | 5042 | /* Read environment and prepend it to the default string. |
| 5059 | Build token table. */ | 5043 | Build token table. */ |
| 5060 | static void | 5044 | static void |