employ string pooling techniques to save off a few more bytes
(probably more than the new “rename” builtin ever required…)
This commit is contained in:
		
							
								
								
									
										4
									
								
								funcs.c
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								funcs.c
									
									
									
									
									
								
							| @@ -5,7 +5,7 @@ | ||||
|  | ||||
| #include "sh.h" | ||||
|  | ||||
| __RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.63 2007/08/19 22:06:26 tg Exp $"); | ||||
| __RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.64 2007/08/19 23:12:21 tg Exp $"); | ||||
|  | ||||
| /* A leading = means assignments before command are kept; | ||||
|  * a leading * means a POSIX special builtin; | ||||
| @@ -3033,7 +3033,7 @@ c_rename(const char **wp) | ||||
| 	    wp[1] == NULL /* first argument */ || | ||||
| 	    wp[2] == NULL /* second argument */ || | ||||
| 	    wp[3] != NULL /* no further args please */) | ||||
| 		bi_errorf("syntax error"); | ||||
| 		bi_errorf(T_synerr); | ||||
| 	else if ((rv = rename(wp[1], wp[2])) != 0) { | ||||
| 		rv = errno; | ||||
| 		bi_errorf("failed: %s", strerror(rv)); | ||||
|   | ||||
							
								
								
									
										27
									
								
								lex.c
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								lex.c
									
									
									
									
									
								
							| @@ -2,7 +2,7 @@ | ||||
|  | ||||
| #include "sh.h" | ||||
|  | ||||
| __RCSID("$MirOS: src/bin/mksh/lex.c,v 1.46 2007/07/23 14:28:52 tg Exp $"); | ||||
| __RCSID("$MirOS: src/bin/mksh/lex.c,v 1.47 2007/08/19 23:12:22 tg Exp $"); | ||||
|  | ||||
| /* Structure to keep track of the lexing state and the various pieces of info | ||||
|  * needed for each particular state. */ | ||||
| @@ -182,22 +182,29 @@ yylex(int cf) | ||||
| 				if (statep->ls_sadelim.style == SADELIM_MAKE && | ||||
| 				    statep->ls_sadelim.num == 1) { | ||||
| 					if (c == /*{*/'}') | ||||
| 						yyerror("syntax error: expected" | ||||
| 					/* { */	    " '%c' before '}'\n", | ||||
| 						    statep->ls_sadelim.delimiter); | ||||
| 						yyerror("%s: expected '%c' %s\n", | ||||
| 						    T_synerr, | ||||
| 						    statep->ls_sadelim.delimiter, | ||||
| 					/*{*/	    "before '}'"); | ||||
| 					else { | ||||
| 						*wp++ = ADELIM; | ||||
| 						*wp++ = c;	/* .delimiter */ | ||||
| 						while ((c = getsc()) != /*{*/ '}') { | ||||
| 							if (!c) { | ||||
| 								yyerror("syntax error: expected" | ||||
| 							/* { */	    " '}' before end of input\n"); | ||||
| 								yyerror("%s: expected '%c' %s\n", | ||||
| 								    T_synerr, | ||||
| 							/*{*/	    '}', "at end of input"); | ||||
| 							} else if (strchr(sadelim_flags[statep->ls_sadelim.flags], c)) { | ||||
| 								*wp++ = CHAR; | ||||
| 								*wp++ = c; | ||||
| 							} else | ||||
| 								yyerror("syntax error: expected" | ||||
| 							/* { */	    " '}' instead of '%c'\n", c); | ||||
| 							} else { | ||||
| 								char Ttmp[15] = "instead of ' '"; | ||||
|  | ||||
| 								Ttmp[12] = c; | ||||
| 								yyerror("%s: expected '%c' %s\n", | ||||
| 								    T_synerr, | ||||
| 							/*{*/	    '}', Ttmp); | ||||
| 							} | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| @@ -709,7 +716,7 @@ yylex(int cf) | ||||
| 		yyerror("no closing quote\n"); | ||||
|  | ||||
| 	if (state == SLETARRAY && statep->ls_sletarray.nparen != -1) | ||||
| 		yyerror("syntax error: ')' missing\n"); | ||||
| 		yyerror("%s: ')' missing\n", T_synerr); | ||||
|  | ||||
| 	/* This done to avoid tests for SHEREDELIM wherever SBASE tested */ | ||||
| 	if (state == SHEREDELIM) | ||||
|   | ||||
							
								
								
									
										4
									
								
								sh.h
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								sh.h
									
									
									
									
									
								
							| @@ -8,7 +8,7 @@ | ||||
| /*	$OpenBSD: c_test.h,v 1.4 2004/12/20 11:34:26 otto Exp $	*/ | ||||
| /*	$OpenBSD: tty.h,v 1.5 2004/12/20 11:34:26 otto Exp $	*/ | ||||
|  | ||||
| #define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.172 2007/08/19 22:06:27 tg Exp $" | ||||
| #define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.173 2007/08/19 23:12:22 tg Exp $" | ||||
| #define MKSH_VERSION "R31 2007/08/19" | ||||
|  | ||||
| #if HAVE_SYS_PARAM_H | ||||
| @@ -440,6 +440,8 @@ EXTERN char shell_flags[FNFLAGS]; | ||||
|  | ||||
| /* null value for variable; comparision pointer for unset */ | ||||
| EXTERN char null[] I__(""); | ||||
| /* helpers for string pooling */ | ||||
| EXTERN const char T_synerr[] I__("syntax error"); | ||||
|  | ||||
| enum temp_type { | ||||
| 	TT_HEREDOC_EXP,	/* expanded heredoc */ | ||||
|   | ||||
							
								
								
									
										6
									
								
								syn.c
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								syn.c
									
									
									
									
									
								
							| @@ -2,7 +2,7 @@ | ||||
|  | ||||
| #include "sh.h" | ||||
|  | ||||
| __RCSID("$MirOS: src/bin/mksh/syn.c,v 1.16 2007/07/01 21:10:29 tg Exp $"); | ||||
| __RCSID("$MirOS: src/bin/mksh/syn.c,v 1.17 2007/08/19 23:12:23 tg Exp $"); | ||||
|  | ||||
| struct nesting_state { | ||||
| 	int start_token;	/* token than began nesting (eg, FOR) */ | ||||
| @@ -729,7 +729,7 @@ syntaxerr(const char *what) | ||||
| 			goto Again; | ||||
| 		} | ||||
| 		/* don't quote the EOF */ | ||||
| 		yyerror("syntax error: unexpected EOF\n"); | ||||
| 		yyerror("%s: unexpected EOF\n", T_synerr); | ||||
| 		/* NOTREACHED */ | ||||
|  | ||||
| 	case LWORD: | ||||
| @@ -756,7 +756,7 @@ syntaxerr(const char *what) | ||||
| 			s = redir; | ||||
| 		} | ||||
| 	} | ||||
| 	yyerror("syntax error: '%s' %s\n", s, what); | ||||
| 	yyerror("%s: '%s' %s\n", T_synerr, s, what); | ||||
| } | ||||
|  | ||||
| static void | ||||
|   | ||||
		Reference in New Issue
	
	Block a user