util  Diff

Differences From Artifact [9504e2c85c]:

  • File ord.c — part of check-in [6a14de1811] at 2019-07-20 23:37:03 on branch trunk — udpate xpriv to use sysv shmem by default; give iaia an option to generate its own types, and allow selecting between 7-bit and 8-bit encodings for ascii (defaulting to 8-bit); update mkpw to work with new iaia; update ord to add flag controlling byte length (7 or 8) for iaia's ascii mode (user: lexi, size: 10625) [annotate] [blame] [check-ins using]

To Artifact [4549cc99f3]:


     1      1   /* [ʞ] ord.c - integer converter
     2      2    *  ~ lexi hale <lexi@hale.su>
     3      3    *  © AGPLv3
     4      4    *  * ord has no dependencies except for libc.
     5      5    *  ? ord converts integers to ascii characters
     6      6    *    and back. written because the only fucking
     7      7    *    way to do this in shell is FUCKING PRINTF.
     8         - *  $ cc ord.c -o ord [-D_IO=(LIBC|POSIX)]
            8  + *  $ cc ord.c -o ord [-D_(POSIX|LIBC)_IO]
     9      9    *  	- the flag D_IO will instruct ord.c whether
    10     10    *  	  to use POSIX io primitives (write and read)
    11     11    *  	  instead of libc primitives (printf). if
    12     12    *  	  you're on a UNIX system, POSIX primitives
    13     13    *  	  will be used by default, but you can block
    14     14    *  	  them with LIBC or force them with POSIX.
    15     15    *  	  if you are on a POSIX- compliant system,
................................................................................
    16     16    *  	  you *should* use POSIX IO, for improved
    17     17    *  	  performance and safety.
    18     18   
    19     19    	TODO: take full advantage of write(2) by storing
    20     20   	      output in single string & making single
    21     21   		  write call */
    22     22   
    23         -#if (defined(__unix__) && _IO != LIBC) || (_IO == POSIX)
           23  +#if (defined(__unix__) && !defined(_POSIX_IO)) && !defined(_LIBC_IO)
    24     24   #	define _POSIX_IO
    25     25   #endif
    26     26   
    27     27   #ifdef _POSIX_IO
    28     28   #	include <unistd.h>
    29     29   #	define say(x) (write(2, (x), (sizeof (x))))
    30     30   #	define print(sz,x) (write(1, (x), (sz)))
    31     31   #	define forposix(x) x
    32     32   #	define forlibc(x)
    33     33   #else
    34     34   #	include <stdio.h>
    35     35   #	define say(x) (fprintf(stderr, (x)))
    36         -#	define print(x) (printf("%s",(x)))
           36  +#	define print(sz,x) (printf("%s",(x)))
    37     37   #	define forposix(x)
    38     38   #	define forlibc(x) x
    39     39   #endif
    40     40   #include <stddef.h>
    41     41   #include <stdint.h>
    42     42   #include <string.h>
    43     43   #include <limits.h>