9front - general discussion about 9front
 help / color / mirror / Atom feed
* ape sscanf %lld
@ 2020-05-01 18:35 ori
  0 siblings, 0 replies; only message in thread
From: ori @ 2020-05-01 18:35 UTC (permalink / raw)
  To: 9front

This implements %lld and %jd for sscanf, also found when
dealing with zic.

diff -r 8006152d13d2 sys/src/ape/lib/ap/stdio/vfscanf.c
--- a/sys/src/ape/lib/ap/stdio/vfscanf.c	Tue Apr 28 20:51:19 2020 -0700
+++ b/sys/src/ape/lib/ap/stdio/vfscanf.c	Fri May 01 11:34:11 2020 -0700
@@ -97,7 +97,13 @@
 		}
 		else
 			width=-1;
-		type=*fmtp=='h' || *fmtp=='l' || *fmtp=='L'?*fmtp++:'n';
+		type = 'n';
+		if(*fmtp=='h' || *fmtp=='l' || *fmtp=='L' || *fmtp=='j')
+			type = *fmtp++;
+		if(type == 'l' && *fmtp == 'l'){
+			type = 'V';
+			fmtp++;
+		}
 		if(!icvt[*fmtp]) goto NonSpecial;
 		if(!(*icvt[*fmtp])(f, &args, store, width, type))
 			return ncvt?ncvt:EOF;
@@ -138,7 +144,7 @@
 static int
 icvt_fixed(FILE *f, va_list *args,
 				int store, int width, int type, int unsgned, int base){
-	unsigned long int num=0;
+	unsigned long long num=0;
 	int sign=1, ndig=0, dig;
 	int c;
 	do
@@ -199,6 +205,8 @@
 			case 'n': *va_arg(*args,  int *)=num*sign; break;
 			case 'l':
 			case 'L': *va_arg(*args,  long *)=num*sign; break;
+			case 'j':
+			case 'V': *va_arg(*args,  long long*)=num*sign; break;
 			}
 			break;
 		case UNSIGNED:
@@ -207,6 +215,8 @@
 			case 'n': *va_arg(*args, unsigned int *)=num*sign; break;
 			case 'l':
 			case 'L': *va_arg(*args, unsigned long *)=num*sign; break;
+			case 'j':
+			case 'V': *va_arg(*args, unsigned long long *)=num*sign; break;
 			}
 			break;
 		case POINTER:



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-05-01 18:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-01 18:35 ape sscanf %lld ori

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 NNTP newsgroup(s).