Commit a460ba3f authored by Lev Walkin's avatar Lev Walkin

things necessary for Sun Solaris 9 @ sparc

parent cc11653d
0.9.8: 2004-Oct-13
0.9.8: 2004-Oct-20
* -X command line option added to asn1c to generate XML DTD.
* Empty SEQUENCE and SET clauses are now allowed.
* Code compiled and tested on Sun Solaris 9 @ sparc.
Improved includes/defines of/for system headers.
0.9.7.1: 2004-Oct-12
......@@ -200,7 +202,7 @@
* Compiler: fixed recursive ASN.1 types inclusion (Severity: low,
Security impact: none).
* Parser: IMPORTS/FROM fixes, now allowing multiple sections.
* Code compiled and checked on PowerPC (@MacOS X). No major portability
* Code compiled and tested on MacOS X (@ PowerPC). No major portability
issues experienced.
0.8.7: 2004-Apr-11 T-version-0-8-7
......
......@@ -2,6 +2,8 @@
tmpfile=".check-parsing.$$.tmp"
diff -a . . 2>/dev/null && diffArgs="-a"
ec=0
for ref in ../tests/*.asn1.-*; do
......@@ -10,7 +12,7 @@ for ref in ../tests/*.asn1.-*; do
echo "Checking $src against $ref"
./asn1c "-$flags" "$src" > "$tmpfile" || ec=$?
if [ $? = 0 ]; then
diff -a -u "$ref" "$tmpfile" || ec=$?
diff $diffArgs -u "$ref" "$tmpfile" || ec=$?
fi
if [ "$1" != "regenerate" ]; then
rm -f "$tmpfile"
......
......@@ -3,7 +3,7 @@ AM_CFLAGS = @ADD_CFLAGS@
check_SCRIPTS = check-assembly.sh
TESTS_ENVIRONMENT= CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}" ./check-assembly.sh
TESTS_ENVIRONMENT= CC="${CC}" CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}" ./check-assembly.sh
if CPLUSPLUS_FOUND
TESTS = check-*.c check-*.cc ## Include C++ test filed (.cc)
......
......@@ -157,7 +157,7 @@ target_os = @target_os@
target_vendor = @target_vendor@
AM_CFLAGS = @ADD_CFLAGS@
check_SCRIPTS = check-assembly.sh
TESTS_ENVIRONMENT = CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}" ./check-assembly.sh
TESTS_ENVIRONMENT = CC="${CC}" CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}" ./check-assembly.sh
@CPLUSPLUS_FOUND_FALSE@TESTS = check-*.c
@CPLUSPLUS_FOUND_TRUE@TESTS = check-*.c check-*.cc ## Include C++ test filed (.cc)
EXTRA_DIST = \
......
......@@ -11,10 +11,10 @@ if [ "x$1" = "x" ]; then
fi
# Compute the .asn1 spec name by the given file name.
source=$(echo "$1" | sed -e 's/.*\///')
source=`echo "$1" | sed -e 's/.*\///'`
testno=`echo "$source" | cut -f2 -d'-' | cut -f1 -d'.'`
args=$(echo "$source" | sed -e 's/\.c[c]*$//')
args=`echo "$source" | sed -e 's/\.c[c]*$//'`
testdir=test-${args}
OFS=$IFS
......@@ -30,9 +30,10 @@ if [ ! -d $testdir ]; then
mkdir $testdir || exit $?
fi
cd $testdir || exit $?
ln -fs ../$source || exit $?
rm -f ./$source 2>/dev/null
ln -fns ../$source || exit $?
asn_module=$(echo ../../../tests/${testno}-*.asn1)
asn_module=`echo ../../../tests/${testno}-*.asn1`
# Create a Makefile for the project.
cat > Makefile <<EOM
......@@ -42,6 +43,8 @@ COMMON_FLAGS= -I. -DEMIT_ASN_DEBUG
CFLAGS=\${COMMON_FLAGS} ${CFLAGS}
CXXFLAGS=\${COMMON_FLAGS} ${CXXFLAGS}
CC=${CC}
all: check-executable
check-executable: compiled-module *.c*
@rm -f *.core
......
......@@ -12,7 +12,6 @@ asn1c_compiled_output(arg_t *arg, const char *fmt, ...) {
int lf_found;
va_list ap;
out_chunk_t *m;
char *buf;
int ret;
switch(arg->target->target) {
......@@ -48,35 +47,30 @@ asn1c_compiled_output(arg_t *arg, const char *fmt, ...) {
if(lf_found)
dst->indented = 0;
/*
* Estimate necessary size.
*/
buf = "";
va_start(ap, fmt);
ret = vsnprintf(buf, 0, fmt, ap);
va_end(ap);
assert(ret >= 0);
/*
* Allocate buffer.
*/
m = calloc(1, sizeof(out_chunk_t));
if(m == NULL) return -1;
m->len = ret + 1;
m->buf = malloc(ret + 1);
if(m->buf == NULL) {
free(m);
return -1;
}
/*
* Fill the buffer.
*/
va_start(ap, fmt);
ret = vsnprintf(m->buf, m->len, fmt, ap);
assert(ret < m->len);
m->len = 16;
do {
void *tmp;
m->len <<= 2;
tmp = realloc(m->buf, m->len);
if(tmp) {
m->buf = (char *)tmp;
} else {
free(m->buf);
free(m);
return -1;
}
va_start(ap, fmt);
ret = vsnprintf(m->buf, m->len, fmt, ap);
va_end(ap);
} while(ret >= (m->len - 1) || ret < 0);
m->len = ret;
va_end(ap);
if(arg->target->target == OT_INCLUDES) {
out_chunk_t *v;
......
......@@ -345,9 +345,11 @@ asn1f_make_known_external_type(const char *type_name) {
int
asn1f_check_known_external_type(const char *type_name) {
void *p = bsearch(&type_name, known_types, known_types_count,
sizeof(known_types[0]), _known_types_cmp);
if(p) return 0;
if(known_types_count) {
void *p = bsearch(&type_name, known_types, known_types_count,
sizeof(known_types[0]), _known_types_cmp);
if(p) return 0;
}
errno = ESRCH;
return -1;
}
......
......@@ -2,6 +2,8 @@
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
* Redistribution and modifications are permitted subject to BSD license.
*/
#define _POSIX_PTHREAD_SEMANTICS /* for Sun */
#define _REENTRANT /* for Sun */
#include <asn_internal.h>
#include <GeneralizedTime.h>
#include <time.h>
......@@ -34,10 +36,15 @@ static struct tm *gmtime_r(const time_t *tloc, struct tm *result) {
}
#define tzset() _tzset()
#define putenv() _putenv()
#define _EMULATE_TIMEGM
#endif /* WIN32 */
#if defined(sun)
#define _EMULATE_TIMEGM
#endif
/*
* Where to look for offset from GMT, Phase I.
* Several platforms are known.
......@@ -87,7 +94,7 @@ static time_t timegm(struct tm *tm) {
char *buf;
tz = getenv("TZ");
_putenv("TZ=UTC");
putenv("TZ=UTC");
tzset();
tloc = mktime(tm);
if (tz) {
......@@ -97,7 +104,7 @@ static time_t timegm(struct tm *tm) {
} else {
buf = "TZ=";
}
_putenv(buf);
putenv(buf);
tzset();
return tloc;
}
......
......@@ -57,7 +57,7 @@ REAL__dump(double d, int canonical, asn_app_consume_bytes_f *cb, void *app_key)
buf = "<NOT-A-NUMBER/>";
buflen = 15;
return (cb(buf, buflen, app_key) < 0) ? -1 : buflen;
} else if(isinf(d)) {
} else if(!finite(d)) {
if(copysign(1.0, d) < 0.0) {
buf = "<MINUS-INFINITY/>";
buflen = 17;
......@@ -416,7 +416,7 @@ asn_double2REAL(REAL_t *st, double dbl_value) {
st->buf[0] = 0x42; /* NaN */
st->buf[1] = 0;
st->size = 1;
} else if(isinf(dbl_value)) {
} else if(!finite(dbl_value)) {
if(copysign(1.0, dbl_value) < 0.0) {
st->buf[0] = 0x41; /* MINUS-INFINITY */
} else {
......
......@@ -12,7 +12,7 @@
#include "config.h"
#endif
#include <stdio.h> /* For fprintf() */
#include <stdio.h> /* For snprintf(3) */
#include <stdlib.h> /* For *alloc(3) */
#include <string.h> /* For memcpy(3) */
#include <sys/types.h> /* For size_t */
......@@ -21,13 +21,23 @@
#include <inttypes.h> /* C99 specifies this file */
#if defined(sun)
#include <ieeefp.h> /* for finite(3) */
#endif
/*
* Earlier FreeBSD version didn't have <stdint.h>,
* 1. Earlier FreeBSD version didn't have <stdint.h>,
* but <inttypes.h> was present.
* 2. Sun Solaris requires <alloca.h> for alloca(3),
* but does not have <stdint.h>.
*/
#if !defined(__FreeBSD__) || !defined(_SYS_INTTYPES_H_) /* Workaround */
#if (!defined(__FreeBSD__) || !defined(_SYS_INTTYPES_H_))
#if defined(sun)
#include <alloca.h> /* For alloca(3) */
#else
#include <stdint.h> /* SUSv2+ and C99 specify this file, for uintXX_t */
#endif
#endif
#ifdef WIN32
#define snprintf _snprintf
......
......@@ -14,20 +14,24 @@ check(char *time_str, time_t expect, int as_gmt) {
tloc = asn_GT2time(&gt, &tm, as_gmt);
printf("%s: [%s] -> %ld == %ld\n",
as_gmt?"GMT":"ofs", time_str, (long)tloc, (long)expect);
if(tloc != -1)
printf("\t%04d-%02d-%02dT%02d:%02d:%02d%+03ld%02ld\n",
if(tloc != -1) {
printf("\t%04d-%02d-%02dT%02d:%02d:%02d%+03ld%02ld\n",
tm.tm_year + 1900,
tm.tm_mon + 1,
tm.tm_mday,
tm.tm_hour,
tm.tm_min,
tm.tm_sec,
(tm.tm_gmtoff / 3600),
labs(tm.tm_gmtoff % 3600)
);
(GMTOFF(tm) / 3600),
labs(GMTOFF(tm) % 3600)
);
}
assert(tloc == expect);
assert(tloc == -1 || as_gmt == 0 || tm.tm_gmtoff == 0);
#ifdef HAVE_TM_GMTOFF
assert(tloc == -1 || as_gmt == 0 || GMTOFF(tm) == 0);
#endif
if(!as_gmt) check(time_str, expect, 1);
}
......
#define __NO_ASN_TABLE__
#include <UTCTime.c>
#define __NO_ASSERT_H__
#include <GeneralizedTime.c>
#define __NO_ASN_TABLE__
#include <UTCTime.c>
#include <constraints.c>
static void
......@@ -23,11 +23,11 @@ check(char *time_str, time_t sample, int as_gmt) {
tm.tm_hour,
tm.tm_min,
tm.tm_sec,
tm.tm_gmtoff
GMTOFF(tm)
);
assert(tloc == sample);
assert(tloc == -1 || as_gmt == 0 || tm.tm_gmtoff == 0);
assert(tloc == -1 || as_gmt == 0 || GMTOFF(tm) == 0);
if(as_gmt) check(time_str, sample, as_gmt);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment