Mercurial > urweb
comparison src/c/urweb.c @ 467:3f1b9231a37b
Inserted a NULL value
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 06 Nov 2008 15:37:38 -0500 |
parents | 1626dcba13ee |
children | 7cb418e9714f |
comparison
equal
deleted
inserted
replaced
466:1626dcba13ee | 467:3f1b9231a37b |
---|---|
870 sprintf(r, "%lld::int8%n", n, &len); | 870 sprintf(r, "%lld::int8%n", n, &len); |
871 ctx->heap_front += len+1; | 871 ctx->heap_front += len+1; |
872 return r; | 872 return r; |
873 } | 873 } |
874 | 874 |
875 char *uw_Basis_sqlifyIntN(uw_context ctx, uw_Basis_int *n) { | |
876 if (n == NULL) | |
877 return "NULL"; | |
878 else | |
879 return uw_Basis_sqlifyInt(ctx, *n); | |
880 } | |
881 | |
875 char *uw_Basis_sqlifyFloat(uw_context ctx, uw_Basis_float n) { | 882 char *uw_Basis_sqlifyFloat(uw_context ctx, uw_Basis_float n) { |
876 int len; | 883 int len; |
877 char *r; | 884 char *r; |
878 | 885 |
879 uw_check_heap(ctx, FLOATS_MAX + 8); | 886 uw_check_heap(ctx, FLOATS_MAX + 8); |
880 r = ctx->heap_front; | 887 r = ctx->heap_front; |
881 sprintf(r, "%g::float8%n", n, &len); | 888 sprintf(r, "%g::float8%n", n, &len); |
882 ctx->heap_front += len+1; | 889 ctx->heap_front += len+1; |
883 return r; | 890 return r; |
891 } | |
892 | |
893 char *uw_Basis_sqlifyFloatN(uw_context ctx, uw_Basis_float *n) { | |
894 if (n == NULL) | |
895 return "NULL"; | |
896 else | |
897 return uw_Basis_sqlifyFloat(ctx, *n); | |
884 } | 898 } |
885 | 899 |
886 | 900 |
887 uw_Basis_string uw_Basis_sqlifyString(uw_context ctx, uw_Basis_string s) { | 901 uw_Basis_string uw_Basis_sqlifyString(uw_context ctx, uw_Basis_string s) { |
888 char *r, *s2; | 902 char *r, *s2; |
918 strcpy(s2, "'::text"); | 932 strcpy(s2, "'::text"); |
919 ctx->heap_front = s2 + 8; | 933 ctx->heap_front = s2 + 8; |
920 return r; | 934 return r; |
921 } | 935 } |
922 | 936 |
937 uw_Basis_string uw_Basis_sqlifyStringN(uw_context ctx, uw_Basis_string s) { | |
938 if (s == NULL) | |
939 return "NULL"; | |
940 else | |
941 return uw_Basis_sqlifyString(ctx, s); | |
942 } | |
943 | |
923 char *uw_Basis_sqlifyBool(uw_context ctx, uw_Basis_bool b) { | 944 char *uw_Basis_sqlifyBool(uw_context ctx, uw_Basis_bool b) { |
924 if (b == uw_Basis_False) | 945 if (b == uw_Basis_False) |
925 return "FALSE"; | 946 return "FALSE"; |
926 else | 947 else |
927 return "TRUE"; | 948 return "TRUE"; |
949 } | |
950 | |
951 char *uw_Basis_sqlifyBoolN(uw_context ctx, uw_Basis_bool *b) { | |
952 if (b == NULL) | |
953 return "NULL"; | |
954 else | |
955 return uw_Basis_sqlifyBool(ctx, *b); | |
928 } | 956 } |
929 | 957 |
930 char *uw_Basis_sqlifyTime(uw_context ctx, uw_Basis_time t) { | 958 char *uw_Basis_sqlifyTime(uw_context ctx, uw_Basis_time t) { |
931 size_t len; | 959 size_t len; |
932 char *r; | 960 char *r; |
938 len = strftime(r, TIMES_MAX, TIME_FMT, &stm); | 966 len = strftime(r, TIMES_MAX, TIME_FMT, &stm); |
939 ctx->heap_front += len+1; | 967 ctx->heap_front += len+1; |
940 return r; | 968 return r; |
941 } else | 969 } else |
942 return "<Invalid time>"; | 970 return "<Invalid time>"; |
971 } | |
972 | |
973 char *uw_Basis_sqlifyTimeN(uw_context ctx, uw_Basis_time *t) { | |
974 if (t == NULL) | |
975 return "NULL"; | |
976 else | |
977 return uw_Basis_sqlifyTime(ctx, *t); | |
943 } | 978 } |
944 | 979 |
945 char *uw_Basis_ensqlBool(uw_Basis_bool b) { | 980 char *uw_Basis_ensqlBool(uw_Basis_bool b) { |
946 static uw_Basis_int true = 1; | 981 static uw_Basis_int true = 1; |
947 static uw_Basis_int false = 0; | 982 static uw_Basis_int false = 0; |