9base

revived minimalist port of Plan 9 userland to Unix
git clone git://git.suckless.org/9base
Log | Files | Refs | README | LICENSE

fmtrune.c (434B)


      1 /* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
      2 #include <stdarg.h>
      3 #include <string.h>
      4 #include "plan9.h"
      5 #include "fmt.h"
      6 #include "fmtdef.h"
      7 
      8 int
      9 fmtrune(Fmt *f, int r)
     10 {
     11 	Rune *rt;
     12 	char *t;
     13 	int n;
     14 
     15 	if(f->runes){
     16 		rt = (Rune*)f->to;
     17 		FMTRCHAR(f, rt, f->stop, r);
     18 		f->to = rt;
     19 		n = 1;
     20 	}else{
     21 		t = (char*)f->to;
     22 		FMTRUNE(f, t, f->stop, r);
     23 		n = t - (char*)f->to;
     24 		f->to = t;
     25 	}
     26 	f->nfmt += n;
     27 	return 0;
     28 }