Build fix

0 views
Skip to first unread message

Aleksej Saushev

unread,
Dec 16, 2009, 4:43:28 PM12/16/09
to fricas...@googlegroups.com, open-axi...@lists.sourceforge.net
Hello!

I need this for both, FriCAS and OpenAxiom, to build last released versions,
I also think it is good idea anyway:

$NetBSD: patch-ab,v 1.1 2009/12/15 23:36:29 asau Exp $

Reuse strcmp to simplify logic and fix build.
Shared between FriCAS and OpenAxiom.

--- src/hyper/addfile.c.orig 2009-07-10 00:50:28.000000000 +0400
+++ src/hyper/addfile.c 2009-12-15 22:32:55.000000000 +0300
@@ -50,13 +50,7 @@
strpostfix(char *s, char *t)
{
int slen = strlen(s), tlen = strlen(t);
-
- if (tlen > slen)
- return 0;
- while (tlen > 0)
- if (s[--slen] != t[--tlen])
- return 0;
- return 1;
+ return (tlen < slen) && !strcmp(s+slen-tlen, t);
}

/* extend_ht : just checks the name and adds a .ht if needed */


--
HE CE3OH...

Waldek Hebisch

unread,
Dec 17, 2009, 8:03:53 AM12/17/09
to fricas...@googlegroups.com

This simplifies the code, so is worth applying anyway, but what
problem did you have with build? AFAICS both the original
and new version may have trouble with strings having length
bigger than allowed in int, but we are not going to use it
for such strings...

--
Waldek Hebisch
heb...@math.uni.wroc.pl

Aleksej Saushev

unread,
Dec 17, 2009, 11:30:02 AM12/17/09
to fricas...@googlegroups.com, open-axi...@lists.sourceforge.net
Waldek Hebisch <heb...@math.uni.wroc.pl> writes:

Yes, ideally it should be rewritten to utilize PATH_MAX, strlcpy/strlcat
and all. If you wish, I can revisit it and rewrite "htadd" to my taste.

The problem manifests this way (OpenAxiom, but FriCAS behaves similarly):

making ../../i486--netbsdelf/share/hypertex/pages from ../../src/pages directory
for f in `ls "../../i486--netbsdelf/share/hypertex"/pages/*.ht "../../i486--netbsdelf/share/hypertex"/pages/*.pht`; do \
AXIOM="../../i486--netbsdelf" ../../i486--netbsdelf/lib/htadd -s $f || exit 1; done
ht_file_open: Unknown file ../../i486--netbsdelf/share/hypertex/pages/ALIST.ht.ht

Note ".ht.ht" suffix.

I didn't analyze details, I just replaced it with simpler and more
comprehensible (in my opinion) code. Originally the diff was this:

--- src/hyper/addfile.c.orig 2009-07-10 00:50:28.000000000 +0400
+++ src/hyper/addfile.c 2009-12-15 22:32:55.000000000 +0300
@@ -50,13 +50,7 @@
strpostfix(char *s, char *t)
{
int slen = strlen(s), tlen = strlen(t);
-
- if (tlen > slen)
- return 0;
- while (tlen > 0)
- if (s[--slen] != t[--tlen])
- return 0;
- return 1;
+ return (tlen < slen) && !strcmp(s+slen-tlen, t);
}

/* extend_ht : just checks the name and adds a .ht if needed */

@@ -141,7 +135,7 @@
}
else {/** If not I am going to have to append path names to it **/
HTPATH = (char *) getenv("HTPATH");
- if (HTPATH == NULL) {
+ if (HTPATH == NULL || *HTPATH == '\0') {
/** The user does not have a HTPATH, so I will use the the directory
$AXIOM/share/hypertex/pages/ as the default path ***/
char *spad = (char *) getenv("AXIOM");
@@ -182,11 +176,7 @@
static int
pathname(char *name)
{
- while (*name)
- if (*name++ == '/')
- return 1;
-
- return 0;
+ return strchr(name, '/') != NULL;
}

/** This procedure opens the proper HT file **/


--
HE CE3OH...

Waldek Hebisch

unread,
Dec 17, 2009, 1:34:11 PM12/17/09
to fricas...@googlegroups.com

At first glance it looks like possible gcc bug. Namely, if
'strpostfix("ALIST.ht", ".ht")' returns 1, then there should be no
extra suffix. OTOH I can not see why 'strpostfix("ALIST.ht", ".ht")'
could return 0 (except due to compiler bug).


--
Waldek Hebisch
heb...@math.uni.wroc.pl

Reply all
Reply to author
Forward
0 new messages