Merging shaped_arenas into HEAD (complete)

What do you want to see in Armagetron soon? Any new feature ideas? Let's ponder these ground breaking ideas...
User avatar
klax
Project Developer
Posts: 481
Joined: Tue Jun 08, 2004 3:51 pm
Location: Barcelona, Spain
Contact:

Post by klax »

Tested in linux and seems ok.

Before merging to head I think we should solve incompatibilities with windows. Here I post some errors to help to solve them:

Code: Select all

armagetronad\src\tron\gParser.cpp(43) : error C2065: 'strncasecmp' : undeclared identifier
armagetronad\src\tron\gGame.cpp(2736) : error C2065: 'close' : undeclared identifier
armagetronad\src\tron\gParser.cpp(15) : fatal error C1083: Cannot open include file: 'unistd.h': No such file or directory
armagetronad\src\tron\gParser.cpp(109) : error C2057: expected constant expression
armagetronad\src\tron\gParser.cpp(109) : error C2466: cannot allocate an array of constant size 0
armagetronad\src\tron\gParser.cpp(109) : error C2133: 'axisDir' : unknown size
armagetronad\src\tron\gParser.cpp(329) : error C2065: 'mkdir' : undeclared identifier
armagetronad\src\tron\gParser.cpp(356) : error C2065: 'open' : undeclared identifier
The first one: why not use stricmp?
User avatar
philippeqc
Long Poster - Project Developer - Sage
Posts: 1526
Joined: Mon Jul 12, 2004 8:55 am
Location: Stockholm
Contact:

Post by philippeqc »

ok, any windows guru could help me on this. What is the windows equivalent to open() and close()?

fopen and fclose are C++ function. And I'm quite sure that before C++, people had ways to open and close files.

-ph
Canis meus id comedit.
User avatar
Jonathan
A Brave Victim
Posts: 3391
Joined: Thu Feb 03, 2005 12:50 am
Location: Not really lurking anymore

Post by Jonathan »

philippeqc wrote:fopen and fclose are C++ function.
fopen and fclose are portable C (not C++) functions.
open and close are system calls.
ˌɑrməˈɡɛˌtrɑn
User avatar
philippeqc
Long Poster - Project Developer - Sage
Posts: 1526
Joined: Mon Jul 12, 2004 8:55 am
Location: Stockholm
Contact:

Post by philippeqc »

Jonathan wrote:
philippeqc wrote:fopen and fclose are C++ function.
fopen and fclose are portable C (not C++) functions.
open and close are system calls.
libxml2 has many "read" functions. http://xmlsoft.org/html/libxml-parser.html. xmlCtxtReadDoc, xmlCtxtReadFd, xmlCtxtReadFile (need the filename as an argument), xmlCtxtReadIO, xmlCtxtReadMemory.

I was using xmlCtxtReadFd, as we have an inteligent resource fetching function that return file descriptors, and because none of the read function supported a FILE *.

Now, the way I see it is either somehow the full file name of the ressource to load is returned from the resourceFetcher (yuck!), either the resourceFetcher is converted to return a FILE * (easy) and the xml file is loaded all in a buffer for xmlCtxtReadMemory.

Does that seem like a good idea at all?

-ph
Canis meus id comedit.
User avatar
philippeqc
Long Poster - Project Developer - Sage
Posts: 1526
Joined: Mon Jul 12, 2004 8:55 am
Location: Stockholm
Contact:

Post by philippeqc »

update: the buffer option is a good idea, and it has been commited. ;) 2 lines should dissapear out of the compilationi on windows, the open and the close.

About strncasecmp, xmlStrncasecmp should be as portable as the whole xmllib2, and has the advantage of supporting UTF-8. As for UFT-16, I'd be tempted to beleive xmlStrncasecmp has a greater chance of supporting it than strncasecmp. But I've been wrong before on this sort of things.

-ph

for more xml string functions, check http://xmlsoft.org/html/libxml-xmlstring.html
Canis meus id comedit.
Luke-Jr
Dr Z Level
Posts: 2246
Joined: Sun Mar 20, 2005 4:03 pm
Location: IM: luke@dashjr.org

Post by Luke-Jr »

philippeqc wrote:About strncasecmp, xmlStrncasecmp should be as portable as the whole xmllib2, and has the advantage of supporting UTF-8. As for UFT-16, I'd be tempted to beleive xmlStrncasecmp has a greater chance of supporting it than strncasecmp. But I've been wrong before on this sort of things.
I don't think the design makes it even possible to support more than one character set... Besides, who uses UTF-16??
Luke-Jr
Dr Z Level
Posts: 2246
Joined: Sun Mar 20, 2005 4:03 pm
Location: IM: luke@dashjr.org

Post by Luke-Jr »

Jonathan wrote:
philippeqc wrote:fopen and fclose are C++ function.
fopen and fclose are portable C (not C++) functions.
open and close are system calls.
fopen and fclose are C stream-based file opening/closing
open and close are *also* standard C, but for dealing with low level I/O
User avatar
Z-Man
God & Project Admin
Posts: 11767
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne
Contact:

Post by Z-Man »

Luke:
man fopen wrote:CONFORMING TO
The fopen and freopen functions conform to ANSI X3.159-1989 (``ANSI C'').
man open wrote:CONFORMING TO
SVr4, SVID, POSIX, X/OPEN, BSD 4.3. The O_NOFOLLOW and O_DIRECTORY
flags are Linux-specific. One may have to define the _GNU_SOURCE
macro to get their definitions.

The (undefined) effect of O_RDONLY | O_TRUNC various among imple-
mentations. On many systems the file is actually truncated.

The O_DIRECT flag was introduced in SGI IRIX, where it has align-
ment restrictions similar to those of Linux 2.4. IRIX has also a
fcntl(2) call to query appropriate alignments, and sizes. FreeBSD
4.x introduced a flag of same name, but without alignment restric-
tions. Support was added under Linux in kernel version 2.4.10.
Older Linux kernels simply ignore this flag.
Only one of these looks like deserving the title "Standard C".
Luke-Jr
Dr Z Level
Posts: 2246
Joined: Sun Mar 20, 2005 4:03 pm
Location: IM: luke@dashjr.org

Post by Luke-Jr »

klax wrote:The first one: why not use stricmp?
Because stricmp isn't C at all?
Maybe we should do some #define strcasecmp stricmp though
z-man wrote:Only one of these looks like deserving the title "Standard C".
meh.
#undef "Standard C"
#define "Standard C" glibc
:)
User avatar
philippeqc
Long Poster - Project Developer - Sage
Posts: 1526
Joined: Mon Jul 12, 2004 8:55 am
Location: Stockholm
Contact:

Post by philippeqc »

Luke-Jr wrote:I don't think the design makes it even possible to support more than one character set...
Well, I dont know how feasable it was, but the first version of the parser used mostly xml functions for text operations.
Luke-Jr wrote:Besides, who uses UTF-16??
*buzzing sound* I'd like to answer Alex. The question is: "Who are the Chineses, the Thai, the Coreeans, the Arabics (*), or anyone who doesnt speak any of the west europeans languages."

Ok, I might be technically wrong on that one, there is still lots about UTF-8 and UTF-16 that I dont understand, but it just felt better in me to think that I was at least trying a bit to fix that when I wrote the parser.

To luke-jr and Jonathan. Thanks for the open vs fopen explication. Most of my file descriptor and FILE* knowledge comes from a socket programing in Linux book. I'll try to avoid this mistake again.

-ph

(*) Sorry if that sound pejoratif. I'm swimming in a 3 languages envirenment, which mean I'm unable to express myself correctly in either of them. I dont know what is the adjectif to describe all the people that have "Arab" as a mother tongue.
Canis meus id comedit.
User avatar
Lucifer
Project Developer
Posts: 8765
Joined: Sun Aug 15, 2004 3:32 pm
Location: Republic of Texas

Post by Lucifer »

Um, phil? UTF-8 can represent all of those languages, that's why it's the encoding of GNOME. And I think KDE too.

UTF-8 has as its first set of characters the old ASCII set, but it's much bigger than that, using up to 3 bytes to represent a character, which is 8*8*8, or 512 total characters it can contain.

At least, last I checked UTF-8 could handle them all......
Check out my YouTube channel: https://youtube.com/@davefancella?si=H--oCK3k_dQ1laDN

Be the devil's own, Lucifer's my name.
- Iron Maiden
Luke-Jr
Dr Z Level
Posts: 2246
Joined: Sun Mar 20, 2005 4:03 pm
Location: IM: luke@dashjr.org

Post by Luke-Jr »

philippeqc wrote:Ok, I might be technically wrong on that one, there is still lots about UTF-8 and UTF-16 that I dont understand, but it just felt better in me to think that I was at least trying a bit to fix that when I wrote the parser.
UTF-8 and UTF-16 support the same stuff. The difference is that UTF-8 is compatible with ASCII and actually common-use.
philippeqc wrote:(*) Sorry if that sound pejoratif. I'm swimming in a 3 languages envirenment, which mean I'm unable to express myself correctly in either of them. I dont know what is the adjectif to describe all the people that have "Arab" as a mother tongue.
I think Arabic is correct... At least, back when I was in a fansubbing group translating anime, one of the destination languages was Arabic, and our Arabic translator didn't give any hints that there's a better English word for it. ;)
User avatar
klax
Project Developer
Posts: 481
Joined: Tue Jun 08, 2004 3:51 pm
Location: Barcelona, Spain
Contact:

Post by klax »

Very fast m8s!! The open and close errors are gone.

Errors now:

Code: Select all

armagetronad\src\tron\gParser.cpp(43) : error C2065: 'strncasecmp' : undeclared identifier
armagetronad\src\tron\gParser.cpp(15) : fatal error C1083: Cannot open include file: 'unistd.h': No such file or directory
armagetronad\src\tron\gParser.cpp(109) : error C2057: expected constant expression
armagetronad\src\tron\gParser.cpp(109) : error C2466: cannot allocate an array of constant size 0
armagetronad\src\tron\gParser.cpp(109) : error C2133: 'axisDir' : unknown size
armagetronad\src\tron\gParser.cpp(329) : error C2065: 'mkdir' : undeclared identifier
The strncasecmp is solved with this (can anyone commit this?):

Code: Select all

#ifdef WIN32
#define strncasecmp strnicmp
#endif
User avatar
Jonathan
A Brave Victim
Posts: 3391
Joined: Thu Feb 03, 2005 12:50 am
Location: Not really lurking anymore

Post by Jonathan »

Lucifer wrote:Um, phil? UTF-8 can represent all of those languages, that's why it's the encoding of GNOME. And I think KDE too.

UTF-8 has as its first set of characters the old ASCII set, but it's much bigger than that, using up to 3 bytes to represent a character, which is 8*8*8, or 512 total characters it can contain.

At least, last I checked UTF-8 could handle them all......
Everyone read this: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
ˌɑrməˈɡɛˌtrɑn
Luke-Jr
Dr Z Level
Posts: 2246
Joined: Sun Mar 20, 2005 4:03 pm
Location: IM: luke@dashjr.org

Post by Luke-Jr »

Jonathan wrote:Everyone read this: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
Did... a long time ago... back when I was implementing UTF-8 support for the MOO programming language =p
Post Reply