- /* Loglan82 Compiler&Interpreter
+/* Loglan82 Compiler&Interpreter
Copyright (C) 1981-1993 Institute of Informatics, University of Warsaw
Copyright (C) 1993, 1994 LITA, Pau
/* Utility routines */
-
-word entier(x) /* Compute entier (floor) */
-double x;
+/**
+ * Compute entier (floor)
+ */
+word entier(double x)
{
word i;
i = -i;
if ((double)i <= x) return(i); else return(i-1);
}
-} /* end entier */
-
+}
-word shift(x, n) /* shift x by n bits */
-word x, n;
+/**
+ * shift x by n bits
+ */
+word shift(word x, word n)
{
if (n == 0) return (x);
if (n > 0) return (x << n);
else return ( (x >> -n) & ~(~(word)0 << (8*sizeof(word)+n)) );
-} /* end shift */
+}
-char *asciiz(virt) /* Get ASCIIZ string from arrayof char */
-virtaddr *virt;
+/**
+ * Get ASCIIZ string from arrayof char
+ */
+char *asciiz(virtaddr *virt)
{
word am;
int len, i;
return (cp);
}
else errsignal(RTEREFTN); /* reference to none */
-} /* end asciiz */
-
+}
-void addext(fname, ext) /* Add extension to a file name */
-char *fname, *ext;
+/**
+ * Add extension to a file name
+ */
+void addext(char *fname, char *ext)
{
char *cp;
cp = fname;
while (*cp != '\0' && *cp != '.') cp++;
strcpy(cp, ext);
-} /* end addext */
-
+}
void usage()
{
}
-
-void abend(msg) /* Print error message and abort */
-char *msg;
+/**
+ * Print error message and abort
+ */
+void abend(char *msg)
{
fprintf(stderr, "Error: %s\n", msg);
exit(8);
static int ranpat1 = 7, ranpat2 = 503, ranpat3 = 15661;
-void ranset() /* Initialize generator */
+/**
+ * Initialize generator
+ */
+void ranset()
{
long tim;
ranpat1 = tim % 30269;
ranpat2 = tim % 30307;
ranpat3 = tim % 30323;
-} /* end ranset */
-
+}
-double prandom() /* Produce next pseudo random number */
+/**
+ * Produce next pseudo random number
+ */
+double prandom()
{
int i;
double r;
return (r-i);
}
-
-void moveblock(from, to, len) /* Copy a block of memory */
-char *from, *to;
-word len;
+/**
+ * Copy a block of memory
+ */
+void moveblock(char *from, char *to, word len)
{
- while (len-- > 0) *to++ = *from++;
-} /* end moveblock */
-
+ while (len-- > 0) {
+ *to++ = *from++;
+ }
+}
/**************************************************************