9front - general discussion about 9front
 help / color / mirror / Atom feed
From: ori@eigenstate.org
To: 9front@9front.org
Subject: ape sscanf %lld
Date: Fri, 1 May 2020 11:35:43 -0700	[thread overview]
Message-ID: <2FEF219DA98009787EB1F5009C70E299@eigenstate.org> (raw)

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:



                 reply	other threads:[~2020-05-01 18:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2FEF219DA98009787EB1F5009C70E299@eigenstate.org \
    --to=ori@eigenstate.org \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).