ordinarily, lineno must be mksh_uari_t, but edit.c most of all isn’t ready,
so we mitigate a bit (in var.c mostly) and tweak another type already, and
add some checks (mksh_{,u}ari_t must fit into {,unsigned }long) and print
line numbers with %lu already
			
			
This commit is contained in:
		
							
								
								
									
										7
									
								
								Build.sh
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								Build.sh
									
									
									
									
									
								
							| @@ -1,5 +1,5 @@ | ||||
| #!/bin/sh | ||||
| srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.673 2015/04/11 23:28:16 tg Exp $' | ||||
| srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.674 2015/04/19 18:50:35 tg Exp $' | ||||
| #- | ||||
| # Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, | ||||
| #		2011, 2012, 2013, 2014, 2015 | ||||
| @@ -2151,9 +2151,9 @@ cta(uari_has_32_bit, 0 < (mksh_uari_t)(((((mksh_uari_t)1 << 15) << 15) - 1) * 4 | ||||
| cta(uari_wrap_32_bit, | ||||
|     (mksh_uari_t)(((((mksh_uari_t)1 << 15) << 15) - 1) * 4 + 3) > | ||||
|     (mksh_uari_t)(((((mksh_uari_t)1 << 15) << 15) - 1) * 4 + 4)); | ||||
| #define NUM 21 | ||||
| #define NUM 22 | ||||
| #else | ||||
| #define NUM 15 | ||||
| #define NUM 16 | ||||
| #endif | ||||
| /* these are always required */ | ||||
| cta(ari_is_signed, (mksh_ari_t)-1 < (mksh_ari_t)0); | ||||
| @@ -2166,6 +2166,7 @@ cta(sizet_voidptr_same_size, sizeof(size_t) == sizeof(void *)); | ||||
| cta(sizet_funcptr_same_size, sizeof(size_t) == sizeof(void (*)(void))); | ||||
| /* our formatting routines assume this */ | ||||
| cta(ptr_fits_in_long, sizeof(size_t) <= sizeof(long)); | ||||
| cta(ari_fits_in_long, sizeof(mksh_ari_t) <= sizeof(long)); | ||||
| /* for struct alignment people */ | ||||
| 		char padding[64 - NUM]; | ||||
| 	}; | ||||
|   | ||||
| @@ -27,7 +27,7 @@ | ||||
| #include <sys/file.h> | ||||
| #endif | ||||
|  | ||||
| __RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.140 2015/03/07 20:46:28 tg Exp $"); | ||||
| __RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.141 2015/04/19 18:50:36 tg Exp $"); | ||||
|  | ||||
| Trap sigtraps[NSIG + 1]; | ||||
| static struct sigaction Sigact_ign; | ||||
| @@ -275,8 +275,9 @@ c_fc(const char **wp) | ||||
| 		for (hp = rflag ? hlast : hfirst; | ||||
| 		    hp >= hfirst && hp <= hlast; hp += rflag ? -1 : 1) { | ||||
| 			if (!nflag) | ||||
| 				shf_fprintf(shl_stdout, "%d", | ||||
| 				    hist_source->line - (int)(histptr - hp)); | ||||
| 				shf_fprintf(shl_stdout, "%lu", | ||||
| 				    (unsigned long)hist_source->line - | ||||
| 				    (unsigned long)(histptr - hp)); | ||||
| 			shf_putc('\t', shl_stdout); | ||||
| 			/* print multi-line commands correctly */ | ||||
| 			s = *hp; | ||||
|   | ||||
							
								
								
									
										8
									
								
								lex.c
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								lex.c
									
									
									
									
									
								
							| @@ -23,7 +23,7 @@ | ||||
|  | ||||
| #include "sh.h" | ||||
|  | ||||
| __RCSID("$MirOS: src/bin/mksh/lex.c,v 1.199 2015/04/11 22:03:30 tg Exp $"); | ||||
| __RCSID("$MirOS: src/bin/mksh/lex.c,v 1.200 2015/04/19 18:50:36 tg Exp $"); | ||||
|  | ||||
| /* | ||||
|  * states while lexing word | ||||
| @@ -1480,7 +1480,7 @@ getsc_line(Source *s) | ||||
| void | ||||
| set_prompt(int to, Source *s) | ||||
| { | ||||
| 	cur_prompt = to; | ||||
| 	cur_prompt = (uint8_t)to; | ||||
|  | ||||
| 	switch (to) { | ||||
| 	/* command */ | ||||
| @@ -1503,8 +1503,8 @@ set_prompt(int to, Source *s) | ||||
| 				if (*ps1 != '!' || *++ps1 == '!') | ||||
| 					shf_putchar(*ps1++, shf); | ||||
| 				else | ||||
| 					shf_fprintf(shf, "%d", | ||||
| 						s ? s->line + 1 : 0); | ||||
| 					shf_fprintf(shf, "%lu", s ? | ||||
| 					    (unsigned long)s->line + 1 : 0UL); | ||||
| 			ps1 = shf_sclose(shf); | ||||
| 			saved_atemp = ATEMP; | ||||
| 			newenv(E_ERRH); | ||||
|   | ||||
							
								
								
									
										7
									
								
								main.c
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								main.c
									
									
									
									
									
								
							| @@ -34,7 +34,7 @@ | ||||
| #include <locale.h> | ||||
| #endif | ||||
|  | ||||
| __RCSID("$MirOS: src/bin/mksh/main.c,v 1.291 2015/04/11 22:03:30 tg Exp $"); | ||||
| __RCSID("$MirOS: src/bin/mksh/main.c,v 1.292 2015/04/19 18:50:37 tg Exp $"); | ||||
|  | ||||
| extern char **environ; | ||||
|  | ||||
| @@ -1286,8 +1286,9 @@ error_prefix(bool fileline) | ||||
| 	    strcmp(source->file, kshname) != 0) | ||||
| 		shf_fprintf(shl_out, "%s: ", kshname + (*kshname == '-')); | ||||
| 	if (fileline && source && source->file != NULL) { | ||||
| 		shf_fprintf(shl_out, "%s[%d]: ", source->file, | ||||
| 		    source->errline > 0 ? source->errline : source->line); | ||||
| 		shf_fprintf(shl_out, "%s[%lu]: ", source->file, | ||||
| 		    (unsigned long)(source->errline ? | ||||
| 		    source->errline : source->line)); | ||||
| 		source->errline = 0; | ||||
| 	} | ||||
| } | ||||
|   | ||||
							
								
								
									
										4
									
								
								sh.h
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								sh.h
									
									
									
									
									
								
							| @@ -169,7 +169,7 @@ | ||||
| #endif | ||||
|  | ||||
| #ifdef EXTERN | ||||
| __RCSID("$MirOS: src/bin/mksh/sh.h,v 1.723 2015/04/11 23:28:21 tg Exp $"); | ||||
| __RCSID("$MirOS: src/bin/mksh/sh.h,v 1.724 2015/04/19 18:50:37 tg Exp $"); | ||||
| #endif | ||||
| #define MKSH_VERSION "R51 2015/04/11" | ||||
|  | ||||
| @@ -1264,7 +1264,7 @@ EXTERN char *path;		/* copy of either PATH or def_path */ | ||||
| EXTERN const char *def_path;	/* path to use if PATH not set */ | ||||
| EXTERN char *tmpdir;		/* TMPDIR value */ | ||||
| EXTERN const char *prompt; | ||||
| EXTERN int cur_prompt;		/* PS1 or PS2 */ | ||||
| EXTERN uint8_t cur_prompt;	/* PS1 or PS2 */ | ||||
| EXTERN int current_lineno;	/* LINENO value */ | ||||
|  | ||||
| /* | ||||
|   | ||||
							
								
								
									
										8
									
								
								var.c
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								var.c
									
									
									
									
									
								
							| @@ -28,7 +28,7 @@ | ||||
| #include <sys/sysctl.h> | ||||
| #endif | ||||
|  | ||||
| __RCSID("$MirOS: src/bin/mksh/var.c,v 1.189 2015/04/19 18:13:31 tg Exp $"); | ||||
| __RCSID("$MirOS: src/bin/mksh/var.c,v 1.190 2015/04/19 18:50:38 tg Exp $"); | ||||
|  | ||||
| /*- | ||||
|  * Variables | ||||
| @@ -1164,7 +1164,7 @@ unspecial(const char *name) | ||||
| } | ||||
|  | ||||
| static time_t seconds;		/* time SECONDS last set */ | ||||
| static int user_lineno;		/* what user set $LINENO to */ | ||||
| static mksh_uari_t user_lineno;	/* what user set $LINENO to */ | ||||
|  | ||||
| static void | ||||
| getspec(struct tbl *vp) | ||||
| @@ -1198,7 +1198,7 @@ getspec(struct tbl *vp) | ||||
| 		num.i = histsize; | ||||
| 		break; | ||||
| 	case V_LINENO: | ||||
| 		num.i = current_lineno + user_lineno; | ||||
| 		num.u = (mksh_uari_t)current_lineno + user_lineno; | ||||
| 		break; | ||||
| 	case V_LINES: | ||||
| 		num.i = x_lins; | ||||
| @@ -1328,7 +1328,7 @@ setspec(struct tbl *vp) | ||||
| 		break; | ||||
| 	case V_LINENO: | ||||
| 		/* The -1 is because line numbering starts at 1. */ | ||||
| 		user_lineno = num.u - current_lineno - 1; | ||||
| 		user_lineno = num.u - (mksh_uari_t)current_lineno - 1; | ||||
| 		break; | ||||
| 	case V_LINES: | ||||
| 		if (num.i >= MIN_LINS) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user