rev 413 - in trunk: modules/Prosist pr src

SVN User <[email protected]> Sun, 25 Apr 2004 12:21:57 -0400
Newsgroups gmane.comp.lang.prothon.cvs
Message-ID <[email protected]>
Author: bcollins
Date: 2004-04-25 12:21:54 -0400 (Sun, 25 Apr 2004)
New Revision: 413

Modified:
   trunk/modules/Prosist/Prosist.c
   trunk/pr/closure.pr
   trunk/pr/dict.pr
   trunk/pr/int.pr
   trunk/pr/modint.pr
   trunk/pr/prosist.pr
   trunk/pr/re.pr
   trunk/pr/stdio.pr
   trunk/pr/system.pr
   trunk/pr/test.pr
   trunk/src/builtins-core.c
   trunk/src/builtins-dict.c
   trunk/src/pr_snprintf.c
Log:
Fix a lot of compile warnings and cleanup test scripts (eol-style and
executable).


Modified: trunk/modules/Prosist/Prosist.c
===================================================================
--- trunk/modules/Prosist/Prosist.c	2004-04-24 22:40:52 UTC (rev 412)
+++ trunk/modules/Prosist/Prosist.c	2004-04-25 16:21:54 UTC (rev 413)
@@ -53,6 +53,8 @@
 
 // Prosist.c - peristant Prothon db
 
+#include <stdlib.h>
+
 #include <prothon/prothon_dll.h>
 
 #include <apr_strings.h>
@@ -237,7 +239,7 @@
 
 //******************************** obj_to_id ********************************
 psid_t obj_to_id(isp ist, psrec_p psrecp, obj_p obj) {
-	psid_t res;
+	psid_t res = 0;
 	obj_p id_obj, mw_obj;
 	mw_obj = NEW_MW(obj);
 	id_obj = dict_item(ist, psrecp->obj_to_id, mw_obj); if_exc_return -1;
@@ -369,7 +371,7 @@
 void append_store_refs(isp ist, psrec_p psrecp, obj_p obj, int objidx, obj_p store_refs) {
 	psid_t id;
 	obj_p mw_obj, id_obj, id_tuple, proxy_obj;
-	int i, idx=0, plen, tuple_type=FALSE;
+	int i, plen, tuple_type=FALSE;
 
 	mw_obj = NEW_MW(obj);
 	if (obj == OBJ(NONE) || dict_item(ist, psrecp->obj_to_id, mw_obj)) {
@@ -381,7 +383,7 @@
 	id = psrecp->nextid++;
 	id_obj = NEW_INT(id);
 
-	if (id_tuple = get_attr(ist, obj, SYM(__ID__))) {
+	if ((id_tuple = get_attr(ist, obj, SYM(__ID__)))) {
 		apr_status_t aprerr;
 		size_t slen;
 		char *s1, *s2;

Modified: trunk/pr/closure.pr
===================================================================
--- trunk/pr/closure.pr	2004-04-24 22:40:52 UTC (rev 412)
+++ trunk/pr/closure.pr	2004-04-25 16:21:54 UTC (rev 413)
@@ -14,4 +14,4 @@
 c()     # prints 1
 c()     # prints 2
 c()     # prints 3
-    
\ No newline at end of file
+print    

Modified: trunk/pr/dict.pr
===================================================================
--- trunk/pr/dict.pr	2004-04-24 22:40:52 UTC (rev 412)
+++ trunk/pr/dict.pr	2004-04-25 16:21:54 UTC (rev 413)
@@ -33,8 +33,8 @@
 
 print 'all tests passed'
 
-print '\nfollowing should be:  1 (1,2) 3 (3,4)\n'
+print '\nfollowing should be:  1 (1, 2) 3 (3, 4)\n'
 
 for i in e: print i, d.popItem!(),
 
-print '\n'
\ No newline at end of file
+print '\n'

Modified: trunk/pr/int.pr
===================================================================
--- trunk/pr/int.pr	2004-04-24 22:40:52 UTC (rev 412)
+++ trunk/pr/int.pr	2004-04-25 16:21:54 UTC (rev 413)
@@ -1,12 +1,14 @@
-INT=Int()
-with INT:
-	def .__add__(other):
-		print ., "+", other
-		i = ^__add__(other) % 16
-		i.setProto(INT)
-		return i
-i=16
-i.setProto(INT)
-j=4
-j.setProto(INT)
-print i+j
+#!/usr/bin/env prothon
+
+INT=Int()
+with INT:
+	def .__add__(other):
+		print ., "+", other
+		i = ^__add__(other) % 16
+		i.setProto(INT)
+		return i
+i=16
+i.setProto(INT)
+j=4
+j.setProto(INT)
+print i+j


Property changes on: trunk/pr/int.pr
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:eol-style
   + native

Modified: trunk/pr/modint.pr
===================================================================
--- trunk/pr/modint.pr	2004-04-24 22:40:52 UTC (rev 412)
+++ trunk/pr/modint.pr	2004-04-25 16:21:54 UTC (rev 413)
@@ -1,19 +1,21 @@
-# tested code
-
-ModInt = Object()
-with ModInt:
-    .modulo = 10 #default
-    def .__init__(*x):
-        if Len(x): .val = x[0]      # val kludge here
-    def .__add__(other):
-        if .modulo != other.modulo:
-            raise TypeError
-        return (.val + other.val) % .modulo
-        
-Mod16Int = ModInt() 
-Mod16Int.modulo = 16    
-
-i = Mod16Int(27)
-j = Mod16Int(4)
-print "sum is %02i" % (i + j)  # prints 15
-
+#!/usr/bin/env prothon
+
+# tested code
+
+ModInt = Object()
+with ModInt:
+    .modulo = 10 #default
+    def .__init__(*x):
+        if Len(x): .val = x[0]      # val kludge here
+    def .__add__(other):
+        if .modulo != other.modulo:
+            raise TypeError
+        return (.val + other.val) % .modulo
+        
+Mod16Int = ModInt() 
+Mod16Int.modulo = 16    
+
+i = Mod16Int(27)
+j = Mod16Int(4)
+print "sum is %02i" % (i + j)  # prints 15
+


Property changes on: trunk/pr/modint.pr
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:eol-style
   + native

Modified: trunk/pr/prosist.pr
===================================================================
--- trunk/pr/prosist.pr	2004-04-24 22:40:52 UTC (rev 412)
+++ trunk/pr/prosist.pr	2004-04-25 16:21:54 UTC (rev 413)
@@ -1,40 +1,40 @@
-#!/usr/bin/env prothon
-
-# prosist.pr
-
-import Prosist
-
-b = 7.3
-
-c = "hello"
-
-d = ('i', 'am', 'a', 'tuple')
-
-e = 1234
-
-f = {"i":"am", "a":"dict"}
-
-g = Object()
-g.a = 1
-g.b = '2'
-g.c = {'3':{4:'5'}}
-
-a = {1:b, 2:c, 3:[d,e], (4,5): f, 6:g}
-
-db = Prosist('test.pdb', root=a, mode=Prosist.RWTRUNCATE)
-db.close()
-
-db = Prosist('test.pdb')
-x = db.root
-db.close()
-
-print 'these two should match .. '
-print
-print a, a[6].a , a[6].b , a[6].c 
-
-del g.a, g.b, g.c, g, d, c, b, e, f['i'], f['a'], f, a[1], a[2], a[3], a[(4,5)], a[6], a
-a = 1
-
-print
-print x
-#, x[6].a , x[6].b , x[6].c 
+#!/usr/bin/env prothon
+
+# prosist.pr
+
+import Prosist
+
+b = 7.3
+
+c = "hello"
+
+d = ('i', 'am', 'a', 'tuple')
+
+e = 1234
+
+f = {"i":"am", "a":"dict"}
+
+g = Object()
+g.a = 1
+g.b = '2'
+g.c = {'3':{4:'5'}}
+
+a = {1:b, 2:c, 3:[d,e], (4,5): f, 6:g}
+
+db = Prosist('test.pdb', root=a, mode=Prosist.RWTRUNCATE)
+db.close()
+
+db = Prosist('test.pdb')
+x = db.root
+db.close()
+
+print 'these two should match .. '
+print
+print a, a[6].a , a[6].b , a[6].c 
+
+del g.a, g.b, g.c, g, d, c, b, e, f['i'], f['a'], f, a[1], a[2], a[3], a[(4,5)], a[6], a
+a = 1
+
+print
+print x
+#, x[6].a , x[6].b , x[6].c 


Property changes on: trunk/pr/prosist.pr
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:eol-style
   + native

Modified: trunk/pr/re.pr
===================================================================
--- trunk/pr/re.pr	2004-04-24 22:40:52 UTC (rev 412)
+++ trunk/pr/re.pr	2004-04-25 16:21:54 UTC (rev 413)
@@ -1,39 +1,39 @@
-#!/usr/bin/env prothon
-
-import Re
-
-def findAll(r,s):
-	result=[]
-	def foundOne(mo): 
-		&result.append!(mo.group())
-		return ''
-	r.sub(foundOne, s)
-	return result
-
-re = Re.compile("m..k")
-
-s = 'this mark likes to muck around in minks'
-
-print findAll(re, s)
-
-print re.findAll(s)
-
-print re.split(s, 2)
-
-mo = re.search(s, 10)
-
-print mo.group(), mo.groups()
-
-re = Re.compile(" (m..k) (l..e)")
-
-mo = re.search(s, 2, 20)
-
-print mo.group(), mo.groups(), mo.expand(r'grp1:<\1> grp2:<\2>')
-
-print "\n-------- above should look like ...  -------------\n"
-
-print "['mark', 'muck', 'mink']"
-print "['mark', 'muck', 'mink']"
-print "['this ', ' likes to ', ' around in minks']"
-print "mark ('mark')"
-print " mark like (' mark like', 'mark', 'like') grp1:<mark> grp2:<like>"
+#!/usr/bin/env prothon
+
+import Re
+
+def findAll(r,s):
+	result=[]
+	def foundOne(mo): 
+		&result.append!(mo.group())
+		return ''
+	r.sub(foundOne, s)
+	return result
+
+re = Re.compile("m..k")
+
+s = 'this mark likes to muck around in minks'
+
+print findAll(re, s)
+
+print re.findAll(s)
+
+print re.split(s, 2)
+
+mo = re.search(s, 10)
+
+print mo.group(), mo.groups()
+
+re = Re.compile(" (m..k) (l..e)")
+
+mo = re.search(s, 2, 20)
+
+print mo.group(), mo.groups(), mo.expand(r'grp1:<\1> grp2:<\2>')
+
+print "\n-------- above should look like ...  -------------\n"
+
+print "['mark', 'muck', 'mink']"
+print "['mark', 'muck', 'mink']"
+print "['this ', ' likes to ', ' around in minks']"
+print "mark ('mark')"
+print " mark like (' mark like', 'mark', 'like') grp1:<mark> grp2:<like>"


Property changes on: trunk/pr/re.pr
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:eol-style
   + native

Modified: trunk/pr/stdio.pr
===================================================================
--- trunk/pr/stdio.pr	2004-04-24 22:40:52 UTC (rev 412)
+++ trunk/pr/stdio.pr	2004-04-25 16:21:54 UTC (rev 413)
@@ -1,21 +1,21 @@
-#!/usr/bin/env prothon
-
-import File
-
-stdout = File.stdout
-stdin = File.stdin
-stderr = File.stderr
-
-stdout.write("Enter your name: ")
-
-name = stdin.readLine()
-
-stdout.write("Hello " + name)
-
-stderr.write("This is written on stderr\n")
-
-print "Opening test file for stdout"
-
-File.setStdOut(File("stdout.txt", "w+"))
-stdout.write("Should still go to stdout\n")
-File.stdout.write("Should go to stdout.txt file\n")
+#!/usr/bin/env prothon
+
+import File
+
+stdout = File.stdout
+stdin = File.stdin
+stderr = File.stderr
+
+stdout.write("Enter your name: ")
+
+name = stdin.readLine()
+
+stdout.write("Hello " + name)
+
+stderr.write("This is written on stderr\n")
+
+print "Opening test file for stdout"
+
+File.setStdOut(File("stdout.txt", "w+"))
+stdout.write("Should still go to stdout\n")
+File.stdout.write("Should go to stdout.txt file\n")


Property changes on: trunk/pr/stdio.pr
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:eol-style
   + native

Modified: trunk/pr/system.pr
===================================================================
--- trunk/pr/system.pr	2004-04-24 22:40:52 UTC (rev 412)
+++ trunk/pr/system.pr	2004-04-25 16:21:54 UTC (rev 413)
@@ -1,13 +1,13 @@
-#!/usr/bin/env prothon
-
-import OS
-
-print
-print 'The following lines should be:'
-print 'hello'
-print '0'
-print
-
-ret = OS.system("echo hello")
-print ret
+#!/usr/bin/env prothon
+
+import OS
+
+print
+print 'The following lines should be:'
+print 'hello'
+print '0'
+print
+
+ret = OS.system("echo hello")
+print ret
 print
\ No newline at end of file


Property changes on: trunk/pr/system.pr
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:eol-style
   + native

Modified: trunk/pr/test.pr
===================================================================
--- trunk/pr/test.pr	2004-04-24 22:40:52 UTC (rev 412)
+++ trunk/pr/test.pr	2004-04-25 16:21:54 UTC (rev 413)
@@ -3,3 +3,4 @@
 print 'should print h e l l o'
 for i in "hello":
 	print i,
+print

Modified: trunk/src/builtins-core.c
===================================================================
--- trunk/src/builtins-core.c	2004-04-24 22:40:52 UTC (rev 412)
+++ trunk/src/builtins-core.c	2004-04-25 16:21:54 UTC (rev 413)
@@ -132,7 +132,7 @@
 DEF(Object, setProto, FORM_RPARAM) {
 	int m;
 	read_unlock(ist, self);
-	if(m = is_immutable(self))
+	if((m = is_immutable(self)))
 		clr_immutable(self);
 	switch_proto(ist, self, parms[1]);
 	if (m) set_immutable(self);

Modified: trunk/src/builtins-dict.c
===================================================================
--- trunk/src/builtins-dict.c	2004-04-24 22:40:52 UTC (rev 412)
+++ trunk/src/builtins-dict.c	2004-04-25 16:21:54 UTC (rev 413)
@@ -126,7 +126,7 @@
 	dict = dict_d(dict_obj);
 
 	if (((dictlen(dict) * 100) / dictsize(dict)) > DICT_MAX_PERCENT_FULL)
-		dict_d(dict_obj) = dict = dict_realloc(dict);
+		dict_obj->data.ptr = dict = (void *)dict_realloc(dict);
 
 	for (i=hash_in; (key=((dp=dictptr(dict,i))->entry.key)); i++){
 		hash = dp->entry.hash;

Modified: trunk/src/pr_snprintf.c
===================================================================
--- trunk/src/pr_snprintf.c	2004-04-24 22:40:52 UTC (rev 412)
+++ trunk/src/pr_snprintf.c	2004-04-25 16:21:54 UTC (rev 413)
@@ -56,45 +56,15 @@
  * Tsirigotis <[email protected]> for xinetd.
  */
 
-#include "apr.h"
-//#include "apr_private.h"
+#include <apr.h>
+#include <apr_strings.h>
+#include <apr_portable.h>
+#include <apr_lib.h>
 
-#include "apr_lib.h"
-#include "apr_strings.h"
-#include "apr_network_io.h"
-#include "apr_portable.h"
 #include <math.h>
-#if APR_HAVE_CTYPE_H
-#include <ctype.h>
-#endif
-#if APR_HAVE_NETINET_IN_H
-#include <netinet/in.h>
-#endif
-#if APR_HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-#if APR_HAVE_ARPA_INET_H
-#include <arpa/inet.h>
-#endif
-#if APR_HAVE_LIMITS_H
-#include <limits.h>
-#endif
-#if APR_HAVE_STRING_H
-#include <string.h>
-#endif
 
 #include "pr_snprintf.h"
 
-typedef enum {
-    NO = 0, YES = 1
-} boolean_e;
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-#ifndef TRUE
-#define TRUE 1
-#endif
 #define NUL '\0'
 #define WIDE_INT long
 
@@ -226,7 +196,7 @@
  * minimal length string
  */
 
-static char *apr_gcvt(double number, int ndigit, char *buf, boolean_e altform)
+static char *apr_gcvt(double number, int ndigit, char *buf, int altform)
 {
     int sign, decpt;
     register char *p1, *p2;
@@ -298,13 +268,8 @@
 #define INS_CHAR(c, sp, bep, cc)                    \
 {                                                   \
     if (sp) {                                       \
-        if (sp >= bep) {                            \
-            vbuff->curpos = sp;                     \
-            if (flush_func(vbuff))                  \
-                return -1;                          \
-            sp = vbuff->curpos;                     \
-            bep = vbuff->endpos;                    \
-        }                                           \
+        if (sp >= bep)                              \
+            return -1;                              \
         *sp++ = (c);                                \
     }                                               \
     cc++;                                           \
@@ -353,17 +318,6 @@
 while (width > len)
 
 /*
- * Prefix the character ch to the string str
- * Increase length
- * Set the has_prefix flag
- */
-#define PREFIX(str, length, ch)                     \
-    *--str = ch;                                    \
-    length++;                                       \
-    has_prefix=YES;
-
-
-/*
  * Convert num to its decimal format.
  * Return value:
  *   - a pointer to a string containing the number (no sign)
@@ -490,7 +444,7 @@
  * in buf).
  */
 static char *conv_fp(register char format, register double num,
-    boolean_e add_dp, int precision, bool_int *is_negative,
+    int add_dp, int precision, bool_int *is_negative,
     char *buf, int *len)
 {
     register char *s = buf;
@@ -578,8 +532,7 @@
 /*
  * Do format conversion placing the output in buffer
  */
-APR_DECLARE(int) apr_pr_vformatter(int (*flush_func)(apr_vformatter_buff_t *),
-    apr_vformatter_buff_t *vbuff, const char *fmt, pr_arg_p ap)
+APR_DECLARE(int) apr_pr_vformatter(apr_vformatter_buff_t *vbuff, const char *fmt, pr_arg_p ap)
 {
     register char *sp;
     register char *bep;
@@ -613,11 +566,11 @@
     /*
      * Flag variables
      */
-    boolean_e alternate_form;
-    boolean_e print_sign;
-    boolean_e print_blank;
-    boolean_e adjust_precision;
-    boolean_e adjust_width;
+    int alternate_form;
+    int print_sign;
+    int print_blank;
+    int adjust_precision;
+    int adjust_width;
     bool_int is_negative;
 
 	pr_arg_start(ap);
@@ -633,9 +586,9 @@
             /*
              * Default variable settings
              */
-            boolean_e print_something = YES;
+            int print_something = 1;
             adjust = RIGHT;
-            alternate_form = print_sign = print_blank = NO;
+            alternate_form = print_sign = print_blank = 0;
             pad_char = ' ';
             prefix_char = NUL;
 
@@ -652,11 +605,11 @@
                     if (*fmt == '-')
                         adjust = LEFT;
                     else if (*fmt == '+')
-                        print_sign = YES;
+                        print_sign = 1;
                     else if (*fmt == '#')
-                        alternate_form = YES;
+                        alternate_form = 1;
                     else if (*fmt == ' ')
-                        print_blank = YES;
+                        print_blank = 1;
                     else if (*fmt == '0')
                         pad_char = '0';
                     else
@@ -668,25 +621,25 @@
                  */
                 if (apr_isdigit(*fmt)) {
                     STR_TO_DEC(fmt, min_width);
-                    adjust_width = YES;
+                    adjust_width = 1;
                 }
                 else if (*fmt == '*') {
                     min_width = (int) pr_arg_int(ap); if_prerr_rtrn;
                     fmt++;
-                    adjust_width = YES;
+                    adjust_width = 1;
                     if (min_width < 0) {
                         adjust = LEFT;
                         min_width = -min_width;
                     }
                 }
                 else
-                    adjust_width = NO;
+                    adjust_width = 0;
 
                 /*
                  * Check if a precision was specified
                  */
                 if (*fmt == '.') {
-                    adjust_precision = YES;
+                    adjust_precision = 1;
                     fmt++;
                     if (apr_isdigit(*fmt)) {
                         STR_TO_DEC(fmt, precision);
@@ -701,10 +654,10 @@
                         precision = 0;
                 }
                 else
-                    adjust_precision = NO;
+                    adjust_precision = 0;
             }
             else
-                adjust_precision = adjust_width = NO;
+                adjust_precision = adjust_width = 0;
 
             /*
              * Modifier check
@@ -863,7 +816,7 @@
 #endif
                 if (!s) {
                     s = conv_fp(*fmt, fp_num, alternate_form,
-                            (adjust_precision == NO) ? FLOAT_DIGITS : precision,
+                            (adjust_precision == 0) ? FLOAT_DIGITS : precision,
                                 &is_negative, &num_buf[1], &s_len);
                     if (is_negative)
                         prefix_char = '-';
@@ -876,7 +829,7 @@
 
             case 'g':
             case 'G':
-                if (adjust_precision == NO)
+                if (adjust_precision == 0)
                     precision = FLOAT_DIGITS;
                 else if (precision == 0)
                     precision = 1;
@@ -961,7 +914,7 @@
             /*
              * Print the string s. 
              */
-            if (print_something == YES) {
+            if (print_something == 1) {
                 for (i = s_len; i != 0; i--) {
                       INS_CHAR(*s, sp, bep, cc);
                     s++;
@@ -979,15 +932,6 @@
 }
 
 
-static int snprintf_flush(apr_vformatter_buff_t *vbuff)
-{
-    /* if the buffer fills we have to abort immediately, there is no way
-     * to "flush" an apr_snprintf... there's nowhere to flush it to.
-     */
-    return -1;
-}
-
-
 APR_DECLARE(int) apr_pr_vsnprintf(char *buf, apr_size_t len, const char *format, pr_arg_p ap) {
     int cc;
     apr_vformatter_buff_t vbuff;
@@ -1001,7 +945,7 @@
         vbuff.curpos = buf;
         vbuff.endpos = buf + len - 1;
     }
-    cc = apr_pr_vformatter(snprintf_flush, &vbuff, format, ap);
+    cc = apr_pr_vformatter(&vbuff, format, ap);
 	if (cc == -99) return -99;
     if (len != 0) {
         *vbuff.curpos = '\0';