Release calc version 2.11.0t5.2

This commit is contained in:
Landon Curt Noll
1999-10-05 21:12:27 -07:00
parent ea64a95b90
commit 8cabbd6fb4
8 changed files with 175 additions and 48 deletions

View File

@@ -41,13 +41,13 @@
#
# Put your custom calc library files here.
#
CUSTOM_CALC_FILES= argv.cal halflen.cal
CUSTOM_CALC_FILES= argv.cal halflen.cal pzasusb8.cal
# The custom help files to install
#
# Put your custom help files here.
#
CUSTOM_HELP= argv devnull help sysinfo
CUSTOM_HELP= argv devnull help sysinfo pzasusb8
# Any .h files that are needed by programs that use libcustcalc.a
#
@@ -63,7 +63,7 @@ CUSTOM_H_SRC=
#
# Put your custom .c files here.
#
CUSTOM_SRC= c_argv.c c_devnull.c c_help.c c_sysinfo.c
CUSTOM_SRC= c_argv.c c_devnull.c c_help.c c_sysinfo.c c_pzasusb8.c
# Any .o files that are needed by program that use libcustcalc.a.
# Don't put ${REQUIRED_OBJ} files in this list.
@@ -72,7 +72,7 @@ CUSTOM_SRC= c_argv.c c_devnull.c c_help.c c_sysinfo.c
#
# Put your custom .o files here.
#
CUSTOM_OBJ= c_argv.o c_devnull.o c_help.o c_sysinfo.o
CUSTOM_OBJ= c_argv.o c_devnull.o c_help.o c_sysinfo.o c_pzasusb8.o
##############################################################################
#-=-=-=-=-=-=- Defaults in case you want to build from this dir -=-=-=-=-=-=-#
@@ -590,6 +590,11 @@ c_help.o: ../string.h
c_help.o: ../value.h
c_help.o: ../zmath.h
c_help.o: c_help.c
c_pzasusb8.o: ../custom.h
c_pzasusb8.o: ../have_const.h
c_pzasusb8.o: ../value.h
c_pzasusb8.o: ../zmath.h
c_pzasusb8.o: c_pzasusb8.c
c_sysinfo.o: ../alloc.h
c_sysinfo.o: ../block.h
c_sysinfo.o: ../byteswap.h

72
custom/c_pzasusb8.c Normal file
View File

@@ -0,0 +1,72 @@
/*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby granted.
*
* Ernest Bowen, following Landon Curt Noll
*/
#if defined(CUSTOM)
#include <stdio.h>
#include "../have_const.h"
#include "../value.h"
#include "../custom.h"
#include "../zmath.h"
/*
* c_pzasusb8 - print numereator of real as if its array of HALFs were
* a string of USB8s
*
* given:
* count = 1;
* vals[0] real number;
*
* returns:
* null
*/
/*ARGSUSED*/
VALUE
c_pzasusb8(char *name, int count, VALUE **vals)
{
VALUE result; /* what we will return */
ZVALUE z; /* numerator of the value */
long octet_cnt; /* number of octets in the numerator */
long half_cnt; /* number of HALFs in the numerator */
USB8 *h; /* octet pointer */
long half_len; /* length of a half in octets */
long i;
long j;
/*
* arg check
*/
result.v_type = V_NULL;
if (vals[0]->v_type != V_NUM) {
math_error("Non-real argument for pzasusb8");
/*NOTREACHED*/
}
/*
* look at the numerator
*/
z = vals[0]->v_num->num;
half_len = sizeof(HALF);
octet_cnt = z.len * half_len;
half_cnt = z.len;
/*
* print the octets
*/
h = (USB8 *) z.v;
for (i=0; i < half_cnt; ++i) {
printf("%d:\t", i);
for (j=0; j < half_len; ++j) {
printf("%02x", (int)(*h++));
}
putchar('\n');
}
return result;
}
#endif /* CUSTOM */

View File

@@ -59,6 +59,7 @@ extern VALUE c_argv(char*, int, VALUE**);
extern VALUE c_devnull(char*, int, VALUE**);
extern VALUE c_help(char*, int, VALUE**);
extern VALUE c_sysinfo(char*, int, VALUE**);
extern VALUE c_pzasusb8(char*, int, VALUE**);
#endif /* CUSTOM */
@@ -108,6 +109,9 @@ CONST struct custom cust[] = {
{ "sysinfo", "return a calc #define value",
0, 1, c_sysinfo },
{ "pzasusb8", "print ZCALUE as USB8",
0, 1, c_pzasusb8 },
#endif /* CUSTOM */

50
custom/pzasusb8 Normal file
View File

@@ -0,0 +1,50 @@
NAME
pzasusb8 - print a number in hex octets
SYNOPSIS
custom("pzasusb8", arg)
TYPES
arg real
return null
DESCRIPTION
This custom function prints out the numerator of a real value
in octets. Each HALF value is printed in a separate line.
NOTE: The output will vary depending on the size of a HALF
and the byte order of the system. See:
custom("sysinfo", "BASEB")
custom("sysinfo", "CALC_BYTE_ORDER")
foe details.
This custom function is intented for testing of the general
custom interface.
EXAMPLE
> custom("pzasusb8", 0x01020304050607080910111213141516);
0: 13141516
1: 09101112
2: 05060708
3: 01020304
> custom("pzasusb8", 10^25)
0: 4a000000
1: 16140148
2: 00084595
> printf("%x\n", 10^25);
0x84595161401484a000000
LIMITS
calc must be built with ALLOW_CUSTOM= -DCUSTOM
calc must be executed with a -C arg.
LIBRARY
none
SEE ALSO
custom

29
custom/pzasusb8.cal Normal file
View File

@@ -0,0 +1,29 @@
/*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby granted.
*
* Ernest Bowen, following Landon Curt Noll
*/
print "p(n) prints array in which numerator of n is stored as a";
print "sequence of 2-hex-digits representing unsigned characters.";
print "h(n) printx n in hex notation. This should be the same as";
print "p(n) except for (1) its leading 0x, (2) possible trailing zeros";
print "in p(n), and (3) the order of the hex-digit pairs.";
print "The following example show results for n = isqrt(2e100).";
print "";
define p(n) {custom("pzasusb8", n); print;}
define h(n) = printf("%x\n", n);
n = isqrt(2e100);
print "";
p(n);
h(n);
print "";
print "BASEB: ", custom("sysinfo", "BASEB");
print "CALC_BYTE_ORDER: ", custom("sysinfo", "CALC_BYTE_ORDER");
print "BIG_ENDIAN: ", custom("sysinfo", "BIG_ENDIAN");
print "LITTLE_ENDIAN: ", custom("sysinfo", "LITTLE_ENDIAN");
print "LONG_BITS: ", custom("sysinfo", "LONG_BITS");
print "LONGLONG_BITS: ", custom("sysinfo", "LONGLONG_BITS");