From mnoble at space.mit.edu Thu Jan 31 22:11:17 2008 From: mnoble at space.mit.edu (Michael Noble) Date: Thu Jan 31 22:11:32 2008 Subject: [slang-users] slirp 1.9.4 released Message-ID: <20080131221117.GA11235@svoboda.mit.edu> I am pleased to announce that SLIRP 1.9.4 has been released to http://space.mit.edu/cxc/slirp SLIRP is a vectorizing code generator, aimed primarily at simplifying the process of creating modules for the S-Lang scripting language. It can dramatically reduce the time and effort required to make C, C++, and Fortran code callable directly from the S-Lang interpreter, automatically vectorize functions to take advantage of the powerful numerical and array capabilities native to S-Lang, and even generate Makefiles to automate the build process. Another distinguishing feature, of special interest as multiprocessor and multicore desktops become more prevalent, is that SLIRP can generate parallelizable wrappers for OpenMP-aware compilers. Details of the changes in v1.9.4 are appended below. Regards, Michael S. Noble ------------------------------------ Changes in v1.9.4 1. Provide S-Lang access to Fortran COMMON block variables, via: get_commblock_list: gives names of all common blocks in module get_commblock: retrieves a CommBlock handle to a given block get_commblock_value: retrieves value of named variable in block set_commblock_value: assigns value to named variable in block Common block variables may also be set/get with struct.field notation, such as variable com1 = get_commblock("com1"); print(com1.energy); com1.energy = 1.1F; 2. Support passing CHARACTER arrays to/from Fortran calls. 3. New -fortran_strlen option, to customize where hidden string length args s/be placed in wrappers of Fortran calls accepting CHARACTER args As a result, the internal FTN_STR_LEN argmap has been removed. 4. Allow object code(s) to be specified at slirp invocation ... they will be treated as if they were part of an -ldflags specification and added as link dependencies to the generated module. 5. Improve Makefile distclean: target (Rafael Laboissiere, at, Debian) 6. Generated makefiles: . Now show SLIRP wrapper command used to create them . Have corrected .SUFFIX rule . Fortran compiler FC variable now includes path for disambiguation . If .sl is found at generation time then 'make install' will install it to the S-Lang/slsh subdirectory in $prefix/share 7. Modified some internal usages of array/function dereferencing, for compatibility with SLang 2.1.x. 8. New verbose help (-vh/-vhelp/--vhelp) option, so that rarely used options do not clutter normal -help output 9. Fortran parameter() statements now recognized for array dimensions. 10. Arguments passed to Fortran routines for array dimensions are now automatically made optional from S-Lang scope. 11. OUT annotations now have precedence over IN when both match a pattern. 12. All Fortran function wrappers now emitted to a single .f file, instead of one output .f file for each input .f file wrapped. 13. Search for .dylib shared libs when establishing S-Lang installation location on Darwin, and .dll.a libs on cygwin. 14. Improved documentation on installation, including a README with explicit tips on using configure options to find S-Lang, etc. From troy_slang at piggo.com Tue Feb 12 11:50:37 2008 From: troy_slang at piggo.com (Troy Piggins) Date: Tue Feb 12 11:52:40 2008 Subject: [slang-users] generating random characters Message-ID: <20080212214941@troy.piggo.com> I'm looking at a slang macro for slrn and I wanted to add 3 random characters to a string. Can't find a standard slang function that does this. I did find some random number generators in the gsl module, but am reluctant to use that because not sure how many "regular" slrn users would have extra slang modules installed. I was thinking as a workaround using the internal bash function $RANDOM which generates a random number between 0 and 32767. Then I was going to limit that to an upper limit of 26, convert that to a corresponding alphabetical char and do that 3 times. Seems tedious. I think for the purposes of what I need I could get away with just numbers instead of alphabetical chars and skip the step of upper limit 26, convert to char, and repeat 3 times. I could just set an upper limit of 999 and take a random number. Here's what I came up with: variable rnd= system( "RND=$RANDOM; let 'RND %= 999'; echo $RND"); Trouble is it is always outputting 0. If I use this: variable rnd= system( "RND=$RANDOM; let 'RND %= 999'"); it always outputs 35212. 2 questions: 1. What am I doing wrong above? 2. Is there a better way to do this with standard slang? 3. Is there a simple way to generate random alpha chars? -- Troy Piggins From olecom at gmail.com Tue Feb 12 12:30:01 2008 From: olecom at gmail.com (Oleg Verych) Date: Tue Feb 12 12:30:39 2008 Subject: [slang-users] generating random characters In-Reply-To: <20080212214941@troy.piggo.com> References: <20080212214941@troy.piggo.com> Message-ID: <8499950a0802120430s561af293u5374507c9e80acdf@mail.gmail.com> On Feb 12, 2008 12:50 PM, Troy Piggins wrote: > I'm looking at a slang macro for slrn and I wanted to add 3 random characters > to a string. Can't find a standard slang function that does this. I did find > some random number generators in the gsl module, but am reluctant to use that > because not sure how many "regular" slrn users would have extra slang modules > installed. > > I was thinking as a workaround using the internal bash function $RANDOM which > generates a random number between 0 and 32767. Then I was going to limit that > to an upper limit of 26, convert that to a corresponding alphabetical char and > do that 3 times. Seems tedious. > > I think for the purposes of what I need I could get away with just numbers > instead of alphabetical chars and skip the step of upper limit 26, convert to > char, and repeat 3 times. I could just set an upper limit of 999 and take a > random number. > > Here's what I came up with: > > variable rnd= system( "RND=$RANDOM; let 'RND %= 999'; echo $RND"); > > Trouble is it is always outputting 0. maybe it's return code, that matters? (Just some general stuff) olecom@flower:/tmp/blinux$ a() { RND=$RANDOM; let 'RND %= 999'; return $RND; } olecom@flower:/tmp/blinux$ a olecom@flower:/tmp/blinux$ $? bash: 181: command not found olecom@flower:/tmp/blinux$ a olecom@flower:/tmp/blinux$ $? bash: 128: command not found olecom@flower:/tmp/blinux$ a olecom@flower:/tmp/blinux$ $? bash: 250: command not found olecom@flower:/tmp/blinux$ [] > 1. What am I doing wrong above? > 2. Is there a better way to do this with standard slang? > 3. Is there a simple way to generate random alpha chars? olecom@flower:/tmp/blinux$ dd bs=1 count=1 References: <20080212214941@troy.piggo.com> Message-ID: <20080212151317.GA23414@svoboda.mit.edu> > I was thinking as a workaround using the internal bash function > $RANDOM which generates a random number between 0 and 32767. Will all slrn users, e.g. those on Windows, have access to bash? Below is a "random" number generator I've used in several projects, stemming from the linear congruential method described in Knuth's "The Art of Computer Programming," Vol 2, Section 3.2.1. Hope This Helps, Mike --- private variable rseed = getpid(); private define random() { rseed = (rseed * 0x5DEECEDL + 0xB) & ((1 shl 30) - 1); (rseed shr 6) / ((1 shl 24) * 1.0); } From davis at space.mit.edu Tue Feb 12 17:03:54 2008 From: davis at space.mit.edu (John E. Davis) Date: Tue Feb 12 17:04:43 2008 Subject: [slang-users] generating random characters In-Reply-To: <20080212151317.GA23414@svoboda.mit.edu> References: <20080212214941@troy.piggo.com> <20080212151317.GA23414@svoboda.mit.edu> Message-ID: <200802121703.m1CH3sBo020015@aluche.mit.edu> Michael Noble wrote: > private variable rseed = getpid(); > private define random() >{ > rseed = (rseed * 0x5DEECEDL + 0xB) & ((1 shl 30) - 1); > (rseed shr 6) / ((1 shl 24) * 1.0); >} Another one that is ok for the purposes Troy has in mind is: private variable Random; define srandom (r) { Random = r; } srandom (_time() * getpid()); define random () { Random = (Random*69069U + 1013904243U)&0xFFFFFFFFU; return Random; } define urandom () { return random()/4294967296.0; } Here, urandom() returns a random number between 0 and 1, whereas random returns a random unsigned integer between 0 and 0xFFFFFFFF. FWIW, the next slang release (2.1.4) will include a random number module. The module will feature a generator that according to the "dieharder" battery of tests has slightly better statistical properties than the Mersenne Twister and is about as fast. This module is not yet in the svn repository but will appear on the next update. Good luck, --John From troy_slang at piggo.com Tue Feb 12 20:02:12 2008 From: troy_slang at piggo.com (Troy Piggins) Date: Tue Feb 12 20:03:46 2008 Subject: [slang-users] Re: generating random characters In-Reply-To: <20080212151317.GA23414@svoboda.mit.edu> References: <20080212214941@troy.piggo.com> <20080212151317.GA23414@svoboda.mit.edu> Message-ID: <20080213060015@troy.piggo.com> * Michael Noble is quoted & my replies are inline below : > > I was thinking as a workaround using the internal bash function > > $RANDOM which generates a random number between 0 and 32767. > > Will all slrn users, e.g. those on Windows, have access to bash? No - that is one big problem with my method. > Below is a "random" number generator I've used in several projects, > stemming from the linear congruential method described in Knuth's > "The Art of Computer Programming," Vol 2, Section 3.2.1. > > Hope This Helps, > Mike > > --- > > private variable rseed = getpid(); > private define random() > { > rseed = (rseed * 0x5DEECEDL + 0xB) & ((1 shl 30) - 1); > (rseed shr 6) / ((1 shl 24) * 1.0); > } Thanks Michael. That is a much better way than mine. Might still prefer John's. -- Troy Piggins From troy_slang at piggo.com Tue Feb 12 20:03:37 2008 From: troy_slang at piggo.com (Troy Piggins) Date: Tue Feb 12 20:05:45 2008 Subject: [slang-users] Re: generating random characters In-Reply-To: <200802121703.m1CH3sBo020015@aluche.mit.edu> References: <20080212214941@troy.piggo.com> <20080212151317.GA23414@svoboda.mit.edu> <200802121703.m1CH3sBo020015@aluche.mit.edu> Message-ID: <20080213060217@troy.piggo.com> * John E. Davis is quoted & my replies are inline below : > Michael Noble wrote: > > private variable rseed = getpid(); > > private define random() > >{ > > rseed = (rseed * 0x5DEECEDL + 0xB) & ((1 shl 30) - 1); > > (rseed shr 6) / ((1 shl 24) * 1.0); > >} > > Another one that is ok for the purposes Troy has in mind is: > > private variable Random; > define srandom (r) > { > Random = r; > } > srandom (_time() * getpid()); > > define random () > { > Random = (Random*69069U + 1013904243U)&0xFFFFFFFFU; > return Random; > } > define urandom () > { > return random()/4294967296.0; > } Excellent - that'll do nicely. Thankyou. > Here, urandom() returns a random number between 0 and 1, whereas > random returns a random unsigned integer between 0 and 0xFFFFFFFF. > > FWIW, the next slang release (2.1.4) will include a random number > module. The module will feature a generator that according to the > "dieharder" battery of tests has slightly better statistical > properties than the Mersenne Twister and is about as fast. This > module is not yet in the svn repository but will appear on the next > update. Interesting - thanks for that. -- Troy Piggins From troy_slang at piggo.com Wed Feb 13 07:09:37 2008 From: troy_slang at piggo.com (Troy Piggins) Date: Wed Feb 13 07:10:55 2008 Subject: [slang-users] Re: generating random characters In-Reply-To: <200802121703.m1CH3sBo020015@aluche.mit.edu> References: <20080212214941@troy.piggo.com> <20080212151317.GA23414@svoboda.mit.edu> <200802121703.m1CH3sBo020015@aluche.mit.edu> Message-ID: <20080213164852@troy.piggo.com> * John E. Davis is quoted & my replies are inline below : > Michael Noble wrote: > > private variable rseed = getpid(); > > private define random() > >{ > > rseed = (rseed * 0x5DEECEDL + 0xB) & ((1 shl 30) - 1); > > (rseed shr 6) / ((1 shl 24) * 1.0); > >} Isn't there a problem with this? Because I'm calling this macro from within slrn, rseed is always giving the pid of the same slrn and so is the same number? > Another one that is ok for the purposes Troy has in mind is: > > private variable Random; > define srandom (r) > { > Random = r; > } > srandom (_time() * getpid()); Perhaps I should have explained more detail about my reasons for wanting random numbers. I have a macro that uses _time to generate the left hand side of my Message-IDs like this 20080213165912@usenet.piggo.com : #v+ define create_msg_id() { variable sd= "usenet"; variable hostname= "piggo.com"; variable tm= localtime( _time ()); return sprintf ("%d%02d%02d%02d%02d%02d@%s.%s", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, sd, hostname); } #v- I was thinking this was unique enough to serve as M-IDs, but a suggestion from Peter J Ross and also a recent experience I had where my system clock jumped forward in the future made me realise that it could be possible to have 2 M-IDs created the same. You'd have to be really, really unlucky to get that considering it would have to be the exact same second, but ... PJR suggest inserting 3 random chars after the numbers like: 20080213165912.xyz@usenet.piggo.com And that's where my little quest here began. So coming back to your suggestion - wouldn't the getpid always generate the same pid if called from within the same slrn process? And if we are trying to prevent a possible mishap with the time-generated LHS of M-ID anyway, I think it'd be dangerous to use _time again for this random part? > define random () > { > Random = (Random*69069U + 1013904243U)&0xFFFFFFFFU; > return Random; > } > define urandom () > { > return random()/4294967296.0; > } > > Here, urandom() returns a random number between 0 and 1, whereas > random returns a random unsigned integer between 0 and 0xFFFFFFFF. I'd be after a random number between 0 and 999 for my purposes :) > FWIW, the next slang release (2.1.4) will include a random number > module. The module will feature a generator that according to the > "dieharder" battery of tests has slightly better statistical > properties than the Mersenne Twister and is about as fast. This > module is not yet in the svn repository but will appear on the next > update. So it will be part of "standard" s-lang 2.1.4? Any idea how far away that release is? Or with all your time spent at the moment on the slrn-mafia chasing a release, am I asking a bit much? :) -- Troy Piggins | http://piggo.com/~troy "At my house, we call them 'Uh-Oh's.'" From davis at space.mit.edu Wed Feb 13 09:09:06 2008 From: davis at space.mit.edu (John E. Davis) Date: Wed Feb 13 09:09:58 2008 Subject: [slang-users] Re: generating random characters In-Reply-To: <20080213164852@troy.piggo.com> References: <20080212214941@troy.piggo.com> <20080212151317.GA23414@svoboda.mit.edu> <200802121703.m1CH3sBo020015@aluche.mit.edu> <20080213164852@troy.piggo.com> Message-ID: <200802130909.m1D996Jk016543@aluche.mit.edu> Troy Piggins wrote: >> > private variable rseed = getpid(); >> > private define random() >> >{ >> > rseed = (rseed * 0x5DEECEDL + 0xB) & ((1 shl 30) - 1); >> > (rseed shr 6) / ((1 shl 24) * 1.0); >> >} > > Isn't there a problem with this? Because I'm calling this macro from within > slrn, rseed is always giving the pid of the same slrn and so is the same > number? Each time the random function is called, rseed will change. Its initial value is that of the pid. [...] > So coming back to your suggestion - wouldn't the getpid always generate the > same pid if called from within the same slrn process? And if we are trying to The idea is that you call random each time you want a pseudo random number. getpid is only used once to initialize the value. > prevent a possible mishap with the time-generated LHS of M-ID anyway, I think > it'd be dangerous to use _time again for this random part? You have to seed the random number generator is some way. Using the current time and process id are typical ways to do this. And this only needs to happen once. >> define random () >> { >> Random = (Random*69069U + 1013904243U)&0xFFFFFFFFU; >> return Random; >> } >> define urandom () >> { >> return random()/4294967296.0; >> } >> >> Here, urandom() returns a random number between 0 and 1, whereas >> random returns a random unsigned integer between 0 and 0xFFFFFFFF. > > I'd be after a random number between 0 and 999 for my purposes :) If you use the above definition of random, then use: r = random() mod 1000; >> FWIW, the next slang release (2.1.4) will include a random number >> module. The module will feature a generator that according to the [...] > So it will be part of "standard" s-lang 2.1.4? Any idea how far away that > release is? Or with all your time spent at the moment on the slrn-mafia > chasing a release, am I asking a bit much? :) It will be a standard module in slang-2.1.4. I do not have any release plans at this time-- perhaps sometime in the spring. I plan to make that my last release of the 2.1 series. I hope this clears up your confusion with the random number seed. Thanks, --John From cedre.m at gmail.com Tue Mar 4 11:49:20 2008 From: cedre.m at gmail.com (cedre.m) Date: Tue Mar 4 11:50:08 2008 Subject: [slang-users] [Patch] Use of glibc wcwidth Message-ID: <47a269090803040349qa6079f9ua451472ed5934533@mail.gmail.com> Hello, I am Japanese centos user. I use slang library(ntsysv, system-config-*). Thank you. This patch resolves unicode ambiguous width problem, by wcwidth(glibc). http://www.unicode.org/reports/tr11/#Ambiguous http://mediasrv.ns.ac.yu/unicode/www.unicode.org/unicode/reports/tr11-4/index.htm http://www.stained-g.net/shinichiro/unicode5-ambiguous-width.html http://people.debian.org/~kubota/unicode-symbols-width2.html.en -- Sugiyama cedre.m@gmail.com -------------- next part -------------- # using glibc wcwidth instead of slwcwidth. # cedre.m@gmail.com diff -urN slang-2.1.3/autoconf/configure.ac slang-2.1.3-wcwidth/autoconf/configure.ac --- slang-2.1.3/autoconf/configure.ac 2007-08-30 03:54:49.000000000 +0900 +++ slang-2.1.3-wcwidth/autoconf/configure.ac 2008-03-04 19:08:17.000000000 +0900 @@ -220,6 +220,21 @@ AC_SUBST(GNU_READLINE) AC_SUBST(LIB_READLINE) +gnu_wcwidth=unknown +AC_ARG_WITH([gnu-wcwidth], + [ --without-gnu-wcwidth Don't use the glibc wcwidth.], + gnu_wcwidth=$withval) + +if test "$gnu_wcwidth" != "no"; then + AC_EGREP_CPP(yes,[ +#include +#include +#if defined(__GLIBC__) && defined(_WCHAR_H) && defined(__STDC_ISO_10646__) +yes +#endif +],AC_DEFINE(HAVE_GNU_WCWIDTH,1,[Define if you want glibc wcwidth.])) +fi + JD_GET_MODULES(src/modules.unx) JD_CREATE_MODULE_ORULES diff -urN slang-2.1.3/src/config.hin slang-2.1.3-wcwidth/src/config.hin --- slang-2.1.3/src/config.hin 2007-08-30 12:29:28.000000000 +0900 +++ slang-2.1.3-wcwidth/src/config.hin 2008-03-04 19:08:17.000000000 +0900 @@ -78,6 +78,8 @@ #undef HAVE_SYS_MMAN_H +#undef HAVE_GNU_WCWIDTH + /* Set these to the appropriate values */ #undef SIZEOF_SHORT #undef SIZEOF_INT diff -urN slang-2.1.3/src/slsmg.c slang-2.1.3-wcwidth/src/slsmg.c --- slang-2.1.3/src/slsmg.c 2007-10-14 03:34:10.000000000 +0900 +++ slang-2.1.3-wcwidth/src/slsmg.c 2008-03-04 19:08:17.000000000 +0900 @@ -214,44 +214,46 @@ unsigned char vt100_char; unsigned char ascii; SLwchar_Type unicode; + SLwchar_Type unicode_not_ambiguous; // not_wide ? } ACS_Def_Type; static SLCONST ACS_Def_Type UTF8_ACS_Map[] = { - {'+', '>', 0x2192 }, /* RIGHTWARDS ARROW */ - {',', '<', 0x2190 }, /* LEFTWARDS ARROW */ - {'-', '^', 0x2191 }, /* UPWARDS ARROW */ - {'.', 'v', 0x2193 }, /* DOWNWARDS ARROW */ - {'0', '#', 0x25AE }, /* BLACK VERTICAL RECTANGLE */ - {'`', '+', 0x25C6 }, /* BLACK DIAMOND */ - {'a', ':', 0x2592 }, /* MEDIUM SHADE */ - {'f', '\'', 0x00B0 },/* DEGREE SIGN */ - {'g', '#', 0x00B1 }, /* PLUS-MINUS SIGN */ - {'h', '#', 0x2592 }, /* MEDIUM SHADE */ - {'i', '#', 0x2603 }, /* SNOWMAN */ - {'j', '+', 0x2518 }, /* BOX DRAWINGS LIGHT UP AND LEFT */ - {'k', '+', 0x2510 }, /* BOX DRAWINGS LIGHT DOWN AND LEFT */ - {'l', '+', 0x250c }, /* BOX DRAWINGS LIGHT DOWN AND RIGHT */ - {'m', '+', 0x2514 }, /* BOX DRAWINGS LIGHT UP AND RIGHT */ - {'n', '+', 0x253C }, /* BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL */ - {'o', '~', 0x23BA }, /* HORIZONTAL SCAN LINE-1 */ - {'p', '-', 0x23BB }, /* HORIZONTAL SCAN LINE-3 (ncurses addition) */ - {'q', '-', 0x2500 }, /* BOX DRAWINGS LIGHT HORIZONTAL */ - {'r', '-', 0x23BC }, /* HORIZONTAL SCAN LINE-7 (ncurses addition) */ - {'s', '_', 0x23BD }, /* HORIZONTAL SCAN LINE-9 */ - {'t', '+', 0x251C }, /* BOX DRAWINGS LIGHT VERTICAL AND RIGHT */ - {'u', '+', 0x2524 }, /* BOX DRAWINGS LIGHT VERTICAL AND LEFT */ - {'v', '+', 0x2534 }, /* BOX DRAWINGS LIGHT UP AND HORIZONTAL */ - {'w', '+', 0x252C }, /* BOX DRAWINGS LIGHT DOWN AND HORIZONTAL */ - {'x', '|', 0x2502 }, /* BOX DRAWINGS LIGHT VERTICAL */ - {'y', '<', 0x2264 }, /* LESS-THAN OR EQUAL TO (ncurses addition) */ - {'z', '>', 0x2265 }, /* GREATER-THAN OR EQUAL TO (ncurses addition) */ - {'{', '*', 0x03C0 }, /* GREEK SMALL LETTER PI (ncurses addition) */ - {'|', '!', 0x2260 }, /* NOT EQUAL TO (ncurses addition) */ - {'}', 'f', 0x00A3 }, /* POUND SIGN (ncurses addition) */ - {'~', 'o', 0x00B7 }, /* MIDDLE DOT */ - {0, 0, 0} + {'+', '>', 0x2192, 0}, /* RIGHTWARDS ARROW [A/21AA] */ + {',', '<', 0x2190, 0}, /* LEFTWARDS ARROW [A/21A9] */ + {'-', '^', 0x2191, 0x2303}, /* UPWARDS ARROW [A/2303] */ + {'.', 'v', 0x2193, 0x2304}, /* DOWNWARDS ARROW [A/2304] */ + {'0', '#', 0x25AE, 0}, /* BLACK VERTICAL RECTANGLE */ + {'`', '+', 0x25C6, 0x2666}, /* BLACK DIAMOND [BLACK DIAMOND SUIT] */ + {'a', ':', 0x2592, 0}, /* MEDIUM SHADE [A]. */ + {'f', '\'', 0x00B0, 0xFF9F},/* DEGREE SIGN + [HALFWIDTH KATAKANA SEMI-VOICED SOUND MARK] */ + {'g', '#', 0x00B1, 0}, /* PLUS-MINUS SIGN [A]. */ + {'h', '#', 0x2592, 0}, /* MEDIUM SHADE [A]. */ + {'i', '#', 0x2603, 0}, /* SNOWMAN [N] */ + {'j', '+', 0x2518, 0}, /* BOX DRAWINGS LIGHT UP AND LEFT [A] */ + {'k', '+', 0x2510, 0}, /* BOX DRAWINGS LIGHT DOWN AND LEFT [A] */ + {'l', '+', 0x250c, 0}, /* BOX DRAWINGS LIGHT DOWN AND RIGHT [A] */ + {'m', '+', 0x2514, 0}, /* BOX DRAWINGS LIGHT UP AND RIGHT [A] */ + {'n', '+', 0x253C, 0}, /* BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL [A] */ + {'o', '~', 0x23BA, 0}, /* HORIZONTAL SCAN LINE-1 [N] */ + {'p', '-', 0x23BB, 0}, /* HORIZONTAL SCAN LINE-3 (ncurses addition) [N] */ + {'q', '-', 0x2500, 0}, /* BOX DRAWINGS LIGHT HORIZONTAL [A] */ + {'r', '-', 0x23BC, 0}, /* HORIZONTAL SCAN LINE-7 (ncurses addition) [N] */ + {'s', '_', 0x23BD, 0}, /* HORIZONTAL SCAN LINE-9 [N] */ + {'t', '+', 0x251C, 0}, /* BOX DRAWINGS LIGHT VERTICAL AND RIGHT [A] */ + {'u', '+', 0x2524, 0}, /* BOX DRAWINGS LIGHT VERTICAL AND LEFT [A] */ + {'v', '+', 0x2534, 0}, /* BOX DRAWINGS LIGHT UP AND HORIZONTAL [A] */ + {'w', '+', 0x252C, 0}, /* BOX DRAWINGS LIGHT DOWN AND HORIZONTAL [A] */ + {'x', '|', 0x2502, 0}, /* BOX DRAWINGS LIGHT VERTICAL [A] */ + {'y', '<', 0x2264, 0}, /* LESS-THAN OR EQUAL TO (ncurses addition) [A]. */ + {'z', '>', 0x2265, 0}, /* GREATER-THAN OR EQUAL TO (ncurses addition) [A] */ + {'{', '*', 0x03C0, 0}, /* GREEK SMALL LETTER PI (ncurses addition) [A]. */ + {'|', '!', 0x2260, 0}, /* NOT EQUAL TO (ncurses addition) [A]. */ + {'}', 'f', 0x00A3, 0}, /* POUND SIGN (ncurses addition) [N] */ + {'~', 'o', 0x00B7, 0xFF65},/* MIDDLE DOT [HALFWIDTH KATAKANA MIDDLE DOT] */ + {0, 0, 0, 0} }; #define ACS_MODE_NONE -1 @@ -288,7 +290,12 @@ acs = UTF8_ACS_Map; while (acs->vt100_char != 0) { - ACS_Map[acs->vt100_char] = acs->unicode; + if (SLwchar_wcwidth(acs->unicode) == 1) + ACS_Map[acs->vt100_char] = acs->unicode; + else if (acs->unicode_not_ambiguous) + ACS_Map[acs->vt100_char] = acs->unicode_not_ambiguous; + else + ACS_Map[acs->vt100_char] = acs->ascii; acs++; } break; diff -urN slang-2.1.3/src/slwcwidth.c slang-2.1.3-wcwidth/src/slwcwidth.c --- slang-2.1.3/src/slwcwidth.c 2007-01-11 01:09:07.000000000 +0900 +++ slang-2.1.3-wcwidth/src/slwcwidth.c 2008-03-04 19:08:17.000000000 +0900 @@ -24,8 +24,13 @@ #include "slang.h" #include "_slang.h" +#ifndef HAVE_GNU_WCWIDTH #define DEFINE_PSLWC_WIDTH_TABLE #include "slwcwidth.h" +#else +#include +#define SL_WIDTH_ALOOKUP(y,x) y = wcwidth((wchar_t)x) +#endif static int Ignore_Double_Width = 0; int SLwchar_wcwidth (SLwchar_Type ch) From laurent.perez at unicaen.fr Tue Mar 4 23:01:48 2008 From: laurent.perez at unicaen.fr (Laurent Perez) Date: Tue Mar 4 23:02:18 2008 Subject: [slang-users] new ao module Message-ID: <20080304230148.GA2460@unicaen.fr> Hello all, I uploaded [1] a new module. Slao provide bindings for libao [2], a cross platform audio library. You probably don't need to add beeping abilities to your slang scripts. Slao may be used to generate arbitrary waveforms with your sound card, providing you with a multi channels, low frequency (and sometimes low quality) function generator. Slao can also create and play wav, au and raw files. Regards ; Laurent. Links : [1] http://laurent.perez2.free.fr/comp/slang/modules/modules.html [2] http://www.xiph.org/ao From p.boekholt at gmail.com Wed Mar 5 19:18:47 2008 From: p.boekholt at gmail.com (Paul Boekholt) Date: Wed Mar 5 19:19:32 2008 Subject: [slang-users] Ruby module for S-Lang Message-ID: Hi, I've uploaded a beta version of a module to embed the Ruby interpreter in S-Lang. The module can pass Ruby objects back to S-Lang and call methods on them with the dot operator ("ruby_object.method()"). For now the module only works with Ruby 1.8. You can get it from http://www.cheesit.com/downloads/slang/slruby.html. From cedre.m at gmail.com Tue Mar 11 13:25:31 2008 From: cedre.m at gmail.com (cedre.m) Date: Tue Mar 11 13:26:35 2008 Subject: [slang-users] Re: [Patch] Use of glibc wcwidth In-Reply-To: <47a269090803040349qa6079f9ua451472ed5934533@mail.gmail.com> References: <47a269090803040349qa6079f9ua451472ed5934533@mail.gmail.com> Message-ID: <47a269090803110625n6328593cm85a7e83c743e7642@mail.gmail.com> This is patch for slang(revision:231). 2008/3/4, cedre. m : > Hello, I am Japanese centos user. > I use slang library(ntsysv, system-config-*). Thank you. > > This patch resolves unicode ambiguous width problem, by wcwidth(glibc). > -- Sugiyama cedre.m@gmail.com -------------- next part -------------- diff -ur slang-r231/autoconf/configure.ac slang-r231-ambiguous/autoconf/configure.ac --- slang-r231/autoconf/configure.ac 2008-03-11 20:55:25.000000000 +0900 +++ slang-r231-ambiguous/autoconf/configure.ac 2008-03-11 20:54:51.000000000 +0900 @@ -220,6 +220,21 @@ AC_SUBST(GNU_READLINE) AC_SUBST(LIB_READLINE) +gnu_wcwidth=unknown +AC_ARG_WITH([gnu-wcwidth], + [ --without-gnu-wcwidth Don't use the glibc wcwidth.], + gnu_wcwidth=$withval) + +if test "$gnu_wcwidth" != "no"; then + AC_EGREP_CPP(yes,[ +#include +#include +#if defined(__GLIBC__) && defined(_WCHAR_H) && defined(__STDC_ISO_10646__) +yes +#endif +],AC_DEFINE(HAVE_GNU_WCWIDTH,1,[Define if you want glibc wcwidth.])) +fi + JD_GET_MODULES(src/modules.unx) JD_CREATE_MODULE_ORULES diff -ur slang-r231/src/config.hin slang-r231-ambiguous/src/config.hin --- slang-r231/src/config.hin 2008-03-11 20:55:24.000000000 +0900 +++ slang-r231-ambiguous/src/config.hin 2008-03-11 20:53:09.000000000 +0900 @@ -78,6 +78,8 @@ #undef HAVE_SYS_MMAN_H +#undef HAVE_GNU_WCWIDTH + /* Set these to the appropriate values */ #undef SIZEOF_SHORT #undef SIZEOF_INT diff -ur slang-r231/src/slang.h slang-r231-ambiguous/src/slang.h --- slang-r231/src/slang.h 2008-03-11 20:55:24.000000000 +0900 +++ slang-r231-ambiguous/src/slang.h 2008-03-11 20:36:58.000000000 +0900 @@ -330,6 +330,7 @@ #define SLWCWIDTH_SINGLE_WIDTH 0x0001 /* all double width characters given as single width */ #define SLWCWIDTH_CJK_LEGACY 0x0002 /* Ambiguous characters given width of 2 */ +#define SLWCWIDTH_GLIBC 0x0004 SL_EXTERN int SLwchar_set_wcwidth_flags (int flags); /* The skip_char functions also skip over malformed strings counting each byte diff -ur slang-r231/src/slcommon.c slang-r231-ambiguous/src/slcommon.c --- slang-r231/src/slcommon.c 2008-03-11 20:55:24.000000000 +0900 +++ slang-r231-ambiguous/src/slcommon.c 2008-03-11 20:38:46.000000000 +0900 @@ -150,6 +150,8 @@ { if ((*cjk == 0) || (0==strcmp(cjk,"yes"))) (void) SLwchar_set_wcwidth_flags (SLWCWIDTH_CJK_LEGACY); + else if (0==strcmp(cjk,"glibc")) + (void) SLwchar_set_wcwidth_flags (SLWCWIDTH_GLIBC); } return mode; } diff -ur slang-r231/src/slwcwidth.c slang-r231-ambiguous/src/slwcwidth.c --- slang-r231/src/slwcwidth.c 2008-03-11 20:55:24.000000000 +0900 +++ slang-r231-ambiguous/src/slwcwidth.c 2008-03-11 20:51:35.000000000 +0900 @@ -26,6 +26,9 @@ #define DEFINE_PSLWC_WIDTH_TABLE #include "slwcwidth.h" +#ifdef HAVE_GNU_WCWIDTH +#include +#endif static int Width_Flags = 0; int SLwchar_wcwidth (SLwchar_Type ch) @@ -44,6 +47,10 @@ { if (Width_Flags & SLWCWIDTH_CJK_LEGACY) w = 2; +#ifdef HAVE_GNU_WCWIDTH + else if (Width_Flags & SLWCWIDTH_GLIBC) + w = wcwidth((wchar_t)ch); +#endif else w = 1; } From p.boekholt at gmail.com Tue Apr 1 19:49:58 2008 From: p.boekholt at gmail.com (Paul Boekholt) Date: Tue Apr 1 19:51:03 2008 Subject: [slang-users] slruby 0.0.2 Message-ID: Hi, The second beta of the Ruby module for S-Lang is out. This version should also work with Ruby 1.9. It needs more testing with Ruby 1.9 though, in fact Ruby 1.9 itself is still in development. You can get the module from http://www.cheesit.com/downloads/slang/slruby.html From p.boekholt at gmail.com Tue Apr 15 18:40:07 2008 From: p.boekholt at gmail.com (Paul Boekholt) Date: Tue Apr 15 18:40:48 2008 Subject: [slang-users] slruby 0.0.3 Message-ID: Hi, Version 0.0.3 of the Ruby module is out. - use an extconf.rb to generate the Makefile - fixed a problem when yielding multiple arguments to S-Lang in Ruby 1.9. - added support for the '[]=' method for RubyValues. This means you can use Ruby hashes in S-Lang: slsh> variable x = rb_eval("{}"); slsh> x["foo"]=1; slsh> x[PI]="foo"; slsh> x.inspect(); {"foo"=>1, 3.14159265358979=>"foo"} - S-Lang functions called from Ruby now return an array instead of just the top value on the stack. Get it from http://www.cheesit.com/downloads/slang/slruby From mlichvar at redhat.com Wed Apr 23 17:09:18 2008 From: mlichvar at redhat.com (Miroslav Lichvar) Date: Wed Apr 23 17:10:33 2008 Subject: [slang-users] system wchar functions support? Message-ID: <20080423170918.GA9485@localhost> Hi, I was wondering if there is any interest in using libc functions for handling wide characters? The main benefit would be support of other multibyte encodings than UTF-8. It could be controlled by a configure option. The patch in attachment should demonstrate what I mean, it's not complete, but it allowed me to successfully run some S-Lang applications in non-UTF-8 environment. Comments? -- Miroslav Lichvar -------------- next part -------------- Index: slang.h =================================================================== --- slang.h (revision 233) +++ slang.h (working copy) @@ -47,6 +47,7 @@ # ifndef __unix__ # define __unix__ 1 # endif +# define SYSTEM_WCHAR 1 #endif #if defined(__APPLE__) @@ -282,6 +283,7 @@ /*{{{ UTF-8 and Wide Char support */ +#ifndef SYSTEM_WCHAR #if SLANG_SIZEOF_INT == 4 typedef unsigned int SLwchar_Type; # define SLANG_WCHAR_TYPE SLANG_UINT_TYPE @@ -293,10 +295,18 @@ # define SLang_push_wchar SLang_push_ulong # define SLang_pop_wchar SLang_pop_ulong #endif +#else +# define SLANG_WCHAR_TYPE SLANG_UINT_TYPE +typedef wchar_t SLwchar_Type; +#endif typedef unsigned char SLuchar_Type; /* Maximum multi-byte len for a unicode wchar */ -#define SLUTF8_MAX_MBLEN 6 +#ifndef SYSTEM_WCHAR +# define SLUTF8_MAX_MBLEN 6 +#else +# define SLUTF8_MAX_MBLEN MB_CUR_MAX +#endif /* If argument is 1, force UTF-8 mode on. If argument is 0, force mode off. * If -1, determine mode from the locale. Index: slinclud.h =================================================================== --- slinclud.h (revision 233) +++ slinclud.h (working copy) @@ -30,4 +30,8 @@ # include #endif +#ifdef SYSTEM_WCHAR +# include +#endif + #endif /* _SLANG_INCLUDE_H_ */ Index: slutf8.c =================================================================== --- slutf8.c (revision 233) +++ slutf8.c (working copy) @@ -24,6 +24,8 @@ #include "slang.h" #include "_slang.h" +#ifndef SYSTEM_WCHAR + static unsigned char Len_Map[256] = { 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* - 31 */ @@ -115,9 +117,11 @@ } return w; } +#endif unsigned char *SLutf8_skip_char (unsigned char *s, unsigned char *smax) { +#ifndef SYSTEM_WCHAR unsigned int len; if (s >= smax) @@ -134,6 +138,18 @@ return s + 1; return s + len; +#else + size_t len; + + if (s >= smax) + return s; + + len = mbrlen(s, smax - s, NULL); + if (len <= 1) + return s + 1; + + return s + len; +#endif } SLuchar_Type *SLutf8_skip_chars (SLuchar_Type *s, SLuchar_Type *smax, @@ -145,6 +161,7 @@ n = 0; while ((n < num) && (s < smax)) { +#ifndef SYSTEM_WCHAR unsigned int len = Len_Map[*s]; if (len <= 1) @@ -167,10 +184,19 @@ n++; continue; } - +#else + unsigned int len; + + len = s - SLutf8_skip_char(s, smax); +#endif if (ignore_combining) { +#ifndef SYSTEM_WCHAR SLwchar_Type w = fast_utf8_decode (s, len); +#else + SLwchar_Type w; + SLutf8_decode (s, smax, &w, NULL); +#endif if (0 != SLwchar_wcwidth (w)) n++; s += len; @@ -213,6 +239,7 @@ n = 0; while ((n < num) && (s > smin)) { +#ifndef SYSTEM_WCHAR unsigned char ch; unsigned int dn; @@ -266,6 +293,18 @@ smax = s; } +#else + SLwchar_Type w; + + s--; + if (NULL != SLutf8_decode(s, smax, &w, NULL)) + { + if ((ignore_combining == 0) + || (0 != SLwchar_wcwidth (w))) + n++; + smax = s; + } +#endif } if (dnum != NULL) @@ -313,6 +352,7 @@ unsigned char *SLutf8_decode (unsigned char *u, unsigned char *umax, SLwchar_Type *wp, unsigned int *nconsumedp) { +#ifndef SYSTEM_WCHAR unsigned int len; unsigned char ch; SLwchar_Type w; @@ -362,6 +402,31 @@ return NULL; return u + len; +#else + size_t len; + + if (u >= umax) + { + *wp = 0; + if (nconsumedp != NULL) + *nconsumedp = 0; + return NULL; + } + + len = mbrtowc(wp, u, umax - u, NULL); + if (len <= 0) + { + *wp = 0; + if (nconsumedp != NULL) + *nconsumedp = 1; + return NULL; + } + + if (nconsumedp != NULL) + *nconsumedp = len; + + return u + len; +#endif } @@ -373,6 +438,7 @@ */ SLuchar_Type *SLutf8_encode (SLwchar_Type w, SLuchar_Type *u, unsigned int ulen) { +#ifndef SYSTEM_WCHAR SLuchar_Type *umax = u + ulen; /* U-00000000 - U-0000007F: 0xxxxxxx */ @@ -451,6 +517,18 @@ *u++ = (w & 0x3F)|0x80; return u; +#else + int len; + + if (ulen < MB_CUR_MAX) + return NULL; + + len = wctomb(u, w); + if (len < 0) + return NULL; + + return u + len; +#endif } /* Like SLutf8_encode, but null terminates the result. Index: slcommon.c =================================================================== --- slcommon.c (revision 233) +++ slcommon.c (working copy) @@ -90,6 +90,7 @@ #ifdef HAVE_NL_LANGINFO_CODESET locale = nl_langinfo (CODESET); if ((locale != NULL) && (*locale)) +# ifndef SYSTEM_WCHAR { if ((0 == strcmp (locale, "UTF-8")) || (0 == strcmp (locale, "utf-8")) @@ -99,6 +100,9 @@ return 0; } +# else + return 1; +# endif #endif locale = setlocale (LC_ALL, ""); Index: slsmg.c =================================================================== --- slsmg.c (revision 233) +++ slsmg.c (working copy) @@ -26,6 +26,10 @@ #include "slang.h" #include "_slang.h" +#ifdef HAVE_LANGINFO_H +# include +#endif + typedef struct { int n; /* number of chars written last time */ @@ -177,6 +181,21 @@ tt_Screen_Rows = &SLtt_Screen_Rows; tt_Screen_Cols = &SLtt_Screen_Cols; tt_unicode_ok = &_pSLtt_UTF8_Mode; +#ifdef HAVE_NL_LANGINFO_CODESET +#ifdef SYSTEM_WCHAR + if ((tt_unicode_ok != NULL) && (*tt_unicode_ok > 0)) + { + char *locale; + locale = nl_langinfo (CODESET); + if ((locale != NULL) && (*locale) && + (!((0 == strcmp (locale, "UTF-8")) + || (0 == strcmp (locale, "utf-8")) + || (0 == strcmp (locale, "utf8")) + || (0 == strcmp (locale, "UTF8"))))) + tt_unicode_ok = NULL; + } +#endif +#endif tt_normal_video = SLtt_normal_video; tt_goto_rc = SLtt_goto_rc; Index: slwclut.c =================================================================== --- slwclut.c (revision 233) +++ slwclut.c (working copy) @@ -125,6 +125,8 @@ return 0; } +static int is_of_class (int char_class, SLwchar_Type w); + static void add_char_class (SLwchar_Lut_Type *r, unsigned char char_class) { unsigned int i; @@ -135,7 +137,11 @@ for (i = 0; i < 256; i++) { +#ifndef SYSTEM_WCHAR if (SL_CLASSIFICATION_LOOKUP(i) & char_class) +#else + if (is_of_class(char_class, i)) +#endif lut[i] = 1; } } @@ -149,7 +155,11 @@ return r->lut[wch]; if (r->char_class +#ifndef SYSTEM_WCHAR && (SL_CLASSIFICATION_LOOKUP(wch) & r->char_class)) +#else + && (is_of_class(r->char_class, wch))) +#endif return 1; /* FIXME. I should use a binary search for this... */ Index: slischar.c =================================================================== --- slischar.c (revision 233) +++ slischar.c (working copy) @@ -26,7 +26,9 @@ #include "slang.h" #include "_slang.h" -#define DEFINE_PSLWC_CLASSIFICATION_TABLE +#ifndef SYSTEM_WCHAR +# define DEFINE_PSLWC_CLASSIFICATION_TABLE +#endif #include "slischar.h" #define MODE_VARIABLE _pSLinterp_UTF8_Mode @@ -34,7 +36,11 @@ int SLwchar_islower (SLwchar_Type ch) { if (MODE_VARIABLE) +#ifndef SYSTEM_WCHAR return SL_CLASSIFICATION_LOOKUP(ch) & SLCHARCLASS_LOWER; +#else + return iswlower(ch); +#endif if (ch < 256) return islower ((unsigned char) ch); @@ -45,7 +51,11 @@ int SLwchar_isupper (SLwchar_Type ch) { if (MODE_VARIABLE) +#ifndef SYSTEM_WCHAR return SL_CLASSIFICATION_LOOKUP(ch) & SLCHARCLASS_UPPER; +#else + return iswupper(ch); +#endif if (ch < 256) return isupper ((unsigned char) ch); @@ -56,7 +66,11 @@ int SLwchar_isalpha (SLwchar_Type ch) { if (MODE_VARIABLE) +#ifndef SYSTEM_WCHAR return SL_CLASSIFICATION_LOOKUP(ch) & SLCHARCLASS_ALPHA; +#else + return iswalpha(ch); +#endif if (ch < 256) return isalpha ((unsigned char) ch); @@ -67,7 +81,11 @@ int SLwchar_isxdigit (SLwchar_Type ch) { if (MODE_VARIABLE) +#ifndef SYSTEM_WCHAR return SL_CLASSIFICATION_LOOKUP(ch) & SLCHARCLASS_XDIGIT; +#else + return iswxdigit(ch); +#endif if (ch < 256) return isxdigit ((unsigned char) ch); @@ -78,7 +96,11 @@ int SLwchar_isspace (SLwchar_Type ch) { if (MODE_VARIABLE) +#ifndef SYSTEM_WCHAR return SL_CLASSIFICATION_LOOKUP(ch) & SLCHARCLASS_SPACE; +#else + return iswspace(ch); +#endif if (ch < 256) return isspace ((unsigned char) ch); @@ -89,7 +111,11 @@ int SLwchar_isblank (SLwchar_Type ch) { if (MODE_VARIABLE) +#ifndef SYSTEM_WCHAR return SL_CLASSIFICATION_LOOKUP(ch) & SLCHARCLASS_BLANK; +#else + return iswblank(ch); +#endif return (ch == ' ') || (ch == '\t'); } @@ -97,7 +123,11 @@ int SLwchar_iscntrl (SLwchar_Type ch) { if (MODE_VARIABLE) +#ifndef SYSTEM_WCHAR return SL_CLASSIFICATION_LOOKUP(ch) & SLCHARCLASS_CNTRL; +#else + return iswcntrl(ch); +#endif if (ch < 256) return iscntrl ((unsigned char) ch); @@ -108,7 +138,11 @@ int SLwchar_isprint (SLwchar_Type ch) { if (MODE_VARIABLE) +#ifndef SYSTEM_WCHAR return SL_CLASSIFICATION_LOOKUP(ch) & SLCHARCLASS_PRINT; +#else + return iswprint(ch); +#endif if (ch < 256) return isprint ((unsigned char) ch); @@ -124,11 +158,15 @@ int SLwchar_isdigit (SLwchar_Type ch) { +#ifndef SYSTEM_WCHAR if (MODE_VARIABLE) { unsigned char t = SL_CLASSIFICATION_LOOKUP(ch); return DIGITCLASS(t); } +#else + return iswdigit(ch); +#endif if ((unsigned)ch < 256) return isdigit ((unsigned char) ch); @@ -138,11 +176,15 @@ int SLwchar_isgraph (SLwchar_Type ch) { +#ifndef SYSTEM_WCHAR if (MODE_VARIABLE) { unsigned char t = SL_CLASSIFICATION_LOOKUP(ch); return GRAPHCLASS(t); } +#else + return iswgraph(ch); +#endif if ((unsigned)ch < 256) return isgraph ((unsigned char) ch); @@ -153,10 +195,14 @@ int SLwchar_isalnum (SLwchar_Type ch) { if (MODE_VARIABLE) +#ifndef SYSTEM_WCHAR { unsigned char t = SL_CLASSIFICATION_LOOKUP(ch); return ALNUMCLASS(t); } +#else + return iswalnum(ch); +#endif if ((unsigned)ch < 256) return isalnum ((unsigned char) ch); @@ -168,10 +214,14 @@ int SLwchar_ispunct (SLwchar_Type ch) { if (MODE_VARIABLE) +#ifndef SYSTEM_WCHAR { unsigned char t = SL_CLASSIFICATION_LOOKUP(ch); return PUNCTCLASS(t); } +#else + return iswpunct(ch); +#endif if ((unsigned)ch < 256) return ispunct ((unsigned char) ch); Index: slwcwidth.c =================================================================== --- slwcwidth.c (revision 233) +++ slwcwidth.c (working copy) @@ -24,12 +24,15 @@ #include "slang.h" #include "_slang.h" -#define DEFINE_PSLWC_WIDTH_TABLE -#include "slwcwidth.h" +#ifndef SYSTEM_WCHAR +# define DEFINE_PSLWC_WIDTH_TABLE +# include "slwcwidth.h" +#endif static int Width_Flags = 0; int SLwchar_wcwidth (SLwchar_Type ch) { +#ifndef SYSTEM_WCHAR int w; SL_WIDTH_ALOOKUP(w,ch); @@ -48,6 +51,12 @@ w = 1; } return w; +#else + if (Width_Flags & SLWCWIDTH_SINGLE_WIDTH) + return 1; + + return wcwidth(ch); +#endif } int SLwchar_set_wcwidth_flags (int flags) From laurent.perez at unicaen.fr Thu Apr 24 20:46:37 2008 From: laurent.perez at unicaen.fr (Laurent Perez) Date: Thu Apr 24 20:47:58 2008 Subject: [slang-users] slglade module updated Message-ID: <20080424204637.GA2479@unicaen.fr> Hi, I have updated Christopher Stawarz's SLglade module so that it works with the latest S-Lang / SLgtk versions. You can get it from : http://laurent.perez2.free.fr/comp/slang/modules/modules.html Regards ; Laurent. From p.boekholt at gmail.com Sat Apr 26 12:00:16 2008 From: p.boekholt at gmail.com (Paul Boekholt) Date: Sat Apr 26 12:01:30 2008 Subject: [slang-users] slruby 0.0.4 Message-ID: Hi, Version 0.0.4 of the Ruby module is out. Changes include: - support for accessing S-Lang variables from Ruby - support for passing bstrings to Ruby - Ruby strings are now passed to S-Lang as bstrings Get it from http://www.cheesit.com/downloads/slang/slruby From mcqueenorama at gmail.com Sat Apr 26 21:32:12 2008 From: mcqueenorama at gmail.com (Brian McQueen) Date: Sat Apr 26 21:33:37 2008 Subject: [slang-users] using it in a daemon Message-ID: <5b3fa8f0804261432p2aebb31fp5d62918a18d8394b@mail.gmail.com> I've got a daemon that gathers system statistics on a linux box. I embedded the slang interpreter the other day so the admins can now some up with equations in slang to calculate whatever weird stuff they want to calculate. From davis at space.mit.edu Mon Apr 28 04:31:18 2008 From: davis at space.mit.edu (John E. Davis) Date: Mon Apr 28 04:32:01 2008 Subject: [slang-users] system wchar functions support? In-Reply-To: <20080423170918.GA9485@localhost> References: <20080423170918.GA9485@localhost> Message-ID: <200804280431.m3S4VIVo001764@aluche.mit.edu> Miroslav Lichvar wrote: > I was wondering if there is any interest in using libc functions for > handling wide characters? The main benefit would be support of other > multibyte encodings than UTF-8. It could be controlled by a configure > option. The problem with adding such support to the 2.x series is that it would break binary compatibility. So such a feature would have to wait until version 3, which I have not thought about yet. As such, version 3 is at least a year or two down the road. Perhaps by then UTF-8 will be widespread enough that supporting other multibyte encodings will be unnecessary. >From my point of view, I see more and more people migrating towards UTF-8. Do you have a different sense of where UTF-8 will be in a few years? Thanks, --John From mlichvar at redhat.com Mon Apr 28 15:43:02 2008 From: mlichvar at redhat.com (Miroslav Lichvar) Date: Mon Apr 28 15:44:09 2008 Subject: [slang-users] system wchar functions support? In-Reply-To: <200804280431.m3S4VIVo001764@aluche.mit.edu> References: <20080423170918.GA9485@localhost> <200804280431.m3S4VIVo001764@aluche.mit.edu> Message-ID: <20080428154302.GA29009@localhost> On Mon, Apr 28, 2008 at 12:31:18AM -0400, John E. Davis wrote: > Miroslav Lichvar wrote: > > I was wondering if there is any interest in using libc functions for > > handling wide characters? The main benefit would be support of other > > multibyte encodings than UTF-8. It could be controlled by a configure > > option. > > The problem with adding such support to the 2.x series is that it > would break binary compatibility. In the common case where sizeof(wchar_t) == sizeof(int) == 4 and SLUTF8_MAX_MBLEN == MB_CUR_MAX for UTF-8 it would be compatible, or not? To prevent unexpected problems, the application would need to do something like SLutf8_enable(2) to enable the new behavior for non-UTF-8 locale. > So such a feature would have to > wait until version 3, which I have not thought about yet. As > such, version 3 is at least a year or two down the road. Perhaps by > then UTF-8 will be widespread enough that supporting other multibyte > encodings will be unnecessary. > > From my point of view, I see more and more people migrating towards > UTF-8. Do you have a different sense of where UTF-8 will be in a few > years? No. I was just curious to hear if there are others who would welcome the support. If it was implemented, I could remove an ugly hack in newt (a library for user interfaces) that tries to workaround the problem by constantly redrawing screen. Thanks, -- Miroslav Lichvar From laurent.perez at unicaen.fr Tue Apr 29 09:06:49 2008 From: laurent.perez at unicaen.fr (Laurent Perez) Date: Tue Apr 29 09:07:25 2008 Subject: [slang-users] slxosd-0.2 Message-ID: <20080429090649.GA2485@unicaen.fr> Hi, There is a new slxosd release. It fixes a bug reported by Paul Boekholt. http://laurent.perez2.free.fr/comp/slang/modules/modules.html Thanks. Laurent. From p.boekholt at gmail.com Wed Apr 30 07:14:18 2008 From: p.boekholt at gmail.com (Paul Boekholt) Date: Wed Apr 30 07:14:42 2008 Subject: [slang-users] slxosd-0.2 In-Reply-To: <20080429090649.GA2485@unicaen.fr> References: <20080429090649.GA2485@unicaen.fr> Message-ID: Hi, 2008/4/29, Laurent Perez : > Hi, > > There is a new slxosd release. It fixes a bug reported by Paul Boekholt. > > http://laurent.perez2.free.fr/comp/slang/modules/modules.html Great! However, it still segfaults with this script: #!/usr/bin/env slsh require ("xosd"); variable fp, line, osd, n, t, last_lines, persist, update; variable cmd = "free"; last_lines = 10; % number of lines to print update = 1; % update delay in seconds persist = 10; % time to persist on screen (in seconds) private define create_osd() { variable osd = xosd_create (last_lines); if (-1 == xosd_set_colour (osd, "cornflower blue")) message (xosd_error); if (-1 == xosd_set_outline_colour (osd, "blue")) message (xosd_error); if (-1 == xosd_set_outline_offset (osd, 1)) message (xosd_error); % if (-1 == xosd_set_shadow_offset (osd, 1)) % message (xosd_error); if (-1 == xosd_set_pos (osd, XOSD_top)) message (xosd_error); if (-1 == xosd_set_timeout (osd, persist)) message (xosd_error); return osd; } n = 0; t = 0; forever { n = 0; variable osd; try { fp = popen (cmd, "r"); if (fp == NULL) throw OpenError; osd = create_osd(); while (-1 != fgets (&line, fp)) { if (strlen (line) > 0) { if (n > 0) () = xosd_scroll (osd, 1); () = xosd_print (osd, last_lines - 1, line); n += 1; } } () = fclose (fp); } catch OpenError: { () = xosd_print (osd, last_lines - 1, "Failed to open " + cmd); } sleep (update); } If I change the osd = create_osd(); to osd = NULL; osd = create_osd(); then it seems to work fine. I guess it's a problem in the xosd library. From laurent.perez at unicaen.fr Wed Apr 30 09:51:05 2008 From: laurent.perez at unicaen.fr (Laurent Perez) Date: Wed Apr 30 09:51:43 2008 Subject: [slang-users] slxosd-0.2 In-Reply-To: References: <20080429090649.GA2485@unicaen.fr> Message-ID: <20080430095105.GA2504@unicaen.fr> * Paul Boekholt [2008-04-30 09:14] : > Great! However, it still segfaults with this script: Hi, I can't reproduce this bug here (xosd-2.2.14). Does this script segfaults too ? #!/usr/bin/env slsh require ("xosd"); variable osd; forever { osd = xosd_create (1); sleep (.1); } Thanks. Laurent. From p.boekholt at gmail.com Wed Apr 30 10:16:46 2008 From: p.boekholt at gmail.com (Paul Boekholt) Date: Wed Apr 30 10:17:43 2008 Subject: [slang-users] slxosd-0.2 In-Reply-To: <20080430095105.GA2504@unicaen.fr> References: <20080429090649.GA2485@unicaen.fr> <20080430095105.GA2504@unicaen.fr> Message-ID: Hi, 2008/4/30, Laurent Perez : > I can't reproduce this bug here (xosd-2.2.14). > Does this script segfaults too ? > > #!/usr/bin/env slsh > > require ("xosd"); > > variable osd; > > forever > { > osd = xosd_create (1); > sleep (.1); > } No, now I get Xlib: connection to ":0.0" refused by server Xlib: Maximum number of clients reached I think I was still using the 0.1 version. I've installed 0.2, now it works fine. Sorry! From laurent.perez at unicaen.fr Tue May 13 21:36:11 2008 From: laurent.perez at unicaen.fr (Laurent Perez) Date: Tue May 13 21:37:24 2008 Subject: [slang-users] slgtkdatabox module updated Message-ID: <20080513213611.GC2471@unicaen.fr> Hi, I just uploaded slgtkdatabox-0.3 which reflect changes in GtkDatabox API. Get it from here : http://laurent.perez2.free.fr/comp/slang/modules/modules.html Regards ; Laurent. From p.boekholt at gmail.com Mon May 19 18:41:28 2008 From: p.boekholt at gmail.com (Paul Boekholt) Date: Mon May 19 18:42:27 2008 Subject: [slang-users] slruby 0.0.5 Message-ID: Hi, Version 0.0.5 of the Ruby module is out. - rb_call_method takes the ruby object as the first argument (this was the second argument by the documentation, but didn't work) - added some unit tests -support for passing unsigned integers to Ruby Get it from http://www.cheesit.com/downloads/slang/slruby From mnoble at space.mit.edu Mon May 19 20:43:00 2008 From: mnoble at space.mit.edu (Michael Noble) Date: Mon May 19 20:43:30 2008 Subject: [slang-users] slgtk 0.7.3 released Message-ID: <20080519204300.GA15950@svoboda.mit.edu> Version 0.7.3 of the Gtk module for S-Lang is now available at http://space.mit.edu/cxc/slgtk This is a minor bugfix release, consisting of . Two Makefile patches for Debian compliance (Rafael Laboissiere, at, Debian) . Fix an incorrect attempt at dereferencing in gtkplot.sl . Modified array/function dereferencing in gtkplot.sl, for compatibility with SLang 2.1.x. . Stop contributed rgbwidget.sl from leaving items on stack. . Search for .dylib shared libs when establishing S-Lang install location on Darwin, and .dll.a libs on Cygwin. . Detailed usage info may be viewed for imdisplay by passing "help" option to the functional form or command line wrapper. From mnoble at space.mit.edu Mon May 19 21:23:07 2008 From: mnoble at space.mit.edu (Michael Noble) Date: Mon May 19 21:23:29 2008 Subject: [slang-users] slirp 1.9.5 Message-ID: <20080519212307.GA17710@svoboda.mit.edu> Version 1.9.5 of the SLIRP code generator is available at http://space.mit.edu/cxc/slirp The changes made since v1.9.4 are included below. Enjoy, Michael S. Noble --------------------- 1. Corrected bug in #else clause handling during macro preprocessing (reported by John Houck at space dot mit dot edu) 2. Improved support for parsing macros with continued lines 3. Look for stdint.h during configure & auto map int32_t, etc types 4. Improvements in Fortran wrapping: . include files are now supported . 'entry' keyword is now supported . -nocom switch can be given to shrink module size by not wrapping common blocks when they are not desired 5. Better ignoring of C++ comments embedded within C comments 6. Improved EOF detection when parsing conditional compilation blocks 7. Enhanced man pages with hyphen patch from Rafael L. at Debian 8. Postscript docs discontinued, due to Latex conversion problems From p.boekholt at gmail.com Fri Jun 13 18:24:31 2008 From: p.boekholt at gmail.com (Paul Boekholt) Date: Fri Jun 13 18:25:27 2008 Subject: [slang-users] slruby 0.0.6 Message-ID: Hi, SLruby 0.0.6 is out. - Ruby Bignums are now passed as doubles - Ruby symbols are passed as strings - Ruby function SLang.import_namespace added to import a SLang namespace into a Ruby module Get it from http://www.cheesit.com/downloads/slang/slruby From laurent.perez at unicaen.fr Wed Jun 18 14:49:51 2008 From: laurent.perez at unicaen.fr (Laurent Perez) Date: Wed Jun 18 14:50:09 2008 Subject: [slang-users] inotify module Message-ID: <20080618144951.GB2488@unicaen.fr> Hello, A new S-Lang module for inotify, the file change notification system for Linux kernel is available at : http://laurent.perez2.free.fr/comp/slang/modules/modules.html Regards ; Laurent Perez. From laurent.perez at unicaen.fr Tue Jul 1 20:48:03 2008 From: laurent.perez at unicaen.fr (Laurent Perez) Date: Tue Jul 1 20:48:55 2008 Subject: [slang-users] new exif module Message-ID: <20080701204803.GA2507@unicaen.fr> Hello, A new S-Lang module for retrieving EXIF data from image files is available at : http://laurent.perez2.free.fr/comp/slang/modules/modules.html Regards ; Laurent. From linux4ms at aim.com Thu Jul 24 18:25:44 2008 From: linux4ms at aim.com (Ben Duncan) Date: Thu Jul 24 18:20:02 2008 Subject: [slang-users] Documentation ... Message-ID: <4888C928.7030606@aim.com> Is there a PDF of the HTML "C Library Reference" or at least a tgz version of this html somewhere ? Thanks ... -- Ben Duncan - Business Network Solutions, Inc. 336 Elton Road Jackson MS, 39212 "Never attribute to malice, that which can be adequately explained by stupidity" - Hanlon's Razor From p.boekholt at gmail.com Sat Aug 2 09:57:50 2008 From: p.boekholt at gmail.com (Paul Boekholt) Date: Sat Aug 2 09:58:09 2008 Subject: [slang-users] slruby 0.1.0 Message-ID: Hi, SLruby 0.1.0 is out. - Added tm documentation Get it from http://www.cheesit.com/downloads/slang/slruby.html From laurent.perez at unicaen.fr Fri Sep 5 14:21:39 2008 From: laurent.perez at unicaen.fr (Laurent Perez) Date: Fri Sep 5 14:22:09 2008 Subject: [slang-users] Creating nested structures Message-ID: <20080905142139.GB2007@unicaen.fr> Hello all ; Is there a way to create an interpreter structure from a nested C structure ? struct first { int a; int b; } struct second { int c; struct first d; } How do I create an interpreter structure corresponding to the second C defined structure ? Thanks for your help. Laurent. From davis at space.mit.edu Fri Sep 5 16:42:42 2008 From: davis at space.mit.edu (John E. Davis) Date: Fri Sep 5 16:43:10 2008 Subject: [slang-users] Creating nested structures In-Reply-To: <20080905142139.GB2007@unicaen.fr> References: <20080905142139.GB2007@unicaen.fr> Message-ID: <200809051642.m85GggR0000532@aluche.mit.edu> Laurent Perez wrote: > Is there a way to create an interpreter structure from a nested C > structure ? > > struct first { > int a; > int b; >} > > struct second { > int c; > struct first d; >} > > How do I create an interpreter structure corresponding to the second C > defined structure ? I can tell you the easiest way to answer this precise question, but a more general answer would involve asking more about what you want to do within the interpeter. The easiest way to create a structure that looks like the above is to use: char buf[256]; sprintf (buf, "struct{c=%d, d=struct{a=%d, b=%d}};", second.c, first.a, first.b); (void) SLang_load_string (buf); The use of SLang_load_string has the effect of pushing the structure onto the slang stack. While this will accomplish the stated goal, I am not sure if this is really what you want. Thanks, --John From mnoble at space.mit.edu Sat Sep 6 13:15:46 2008 From: mnoble at space.mit.edu (Michael Noble) Date: Sat Sep 6 13:16:29 2008 Subject: [slang-users] Creating nested structures In-Reply-To: <20080905142139.GB2007@unicaen.fr> References: <20080905142139.GB2007@unicaen.fr> Message-ID: <20080906131546.GA12134@svoboda.mit.edu> > Is there a way to create an interpreter structure from a nested C > structure ? > > struct first { > int a; > int b; > } > > struct second { > int c; > struct first d; > } > > How do I create an interpreter structure corresponding to the second C > defined structure ? Is the discussion at http://mailman.jedsoft.org/pipermail/slang-users-l/2004-January/000029.html of any help? Good Luck, Mike From laurent.perez at unicaen.fr Sat Sep 6 13:24:19 2008 From: laurent.perez at unicaen.fr (Laurent Perez) Date: Sat Sep 6 13:25:29 2008 Subject: [slang-users] Creating nested structures In-Reply-To: <200809051642.m85GggR0000532@aluche.mit.edu> References: <20080905142139.GB2007@unicaen.fr> <200809051642.m85GggR0000532@aluche.mit.edu> Message-ID: <20080906152419.v3rxptnb4wgwgk8w@webmail.unicaen.fr> "John E. Davis" a ??crit??: > The use of SLang_load_string has the effect of pushing the structure > onto the slang stack. While this will accomplish the stated goal, I > am not sure if this is really what you want. Hello John, As you guessed, this is not exactly what I want (anyway, I'am happy to know this trick, thanks). I'am creating a module for the future libusb-1.0, to be able to send low level commands to an usb device from a S-lang script. Some libusb structures are opaque type but others have to be exposed to the interpreter, and some of them have nested fields. Maybe shouldn't I try to mimic C api and find a more convenient way to access fields of such structures from S-lang. Thanks, Laurent. From laurent.perez at unicaen.fr Sat Sep 6 13:45:41 2008 From: laurent.perez at unicaen.fr (Laurent Perez) Date: Sat Sep 6 13:46:30 2008 Subject: [slang-users] Creating nested structures In-Reply-To: <20080906131546.GA12134@svoboda.mit.edu> References: <20080905142139.GB2007@unicaen.fr> <20080906131546.GA12134@svoboda.mit.edu> Message-ID: <20080906154541.9zaidtj34kg04kgg@webmail.unicaen.fr> Michael Noble a wrote?: > Is the discussion at > > http://mailman.jedsoft.org/pipermail/slang-users-l/2004-January/000029.html > > of any help? Hi Mike, I didn't see this discussion while searching through archives, sorry. It looks like what I need, thanks. I will investigate. Thanks again. Laurent. From joerg at alea.gnuu.de Sat Sep 6 20:17:38 2008 From: joerg at alea.gnuu.de (=?UTF-8?Q?J=C3=B6rg?= Sommer) Date: Sat Sep 6 20:24:34 2008 Subject: [slang-users] EXIT_BLOCK not executed on Error Message-ID: Hi, I expect this code prints ?foo? and the error message, but it prints only the error message. % cat /tmp/test.sl define test() { #ifexists push_spot push_spot(); EXIT_BLOCK { pop_spot(); } () = eob(); #else EXIT_BLOCK { message("foo"); } #endif throw NotImplementedError; } test(); % slsh /tmp/test.sl Not Implemented /tmp/test.sl:16:test:Not Implemented I expect % slsh /tmp/test.sl foo Not Implemented /tmp/test.sl:16:test:Not Implemented Is this a bug? Bye, J?rg. -- Der Wille und nicht die Gabe macht den Geber. From davis at space.mit.edu Sun Sep 7 00:20:58 2008 From: davis at space.mit.edu (John E. Davis) Date: Sun Sep 7 00:21:38 2008 Subject: [slang-users] EXIT_BLOCK not executed on Error In-Reply-To: References: Message-ID: <200809070020.m870KwZi013066@aluche.mit.edu> On Sat, 6 Sep 2008 20:17:38 +0000 (UTC), J?rg Sommer wrote: > I expect this code prints ?foo? and the error message, but it prints only > the error message. > > % cat /tmp/test.sl > define test() >{ > #ifexists push_spot > push_spot(); > EXIT_BLOCK > { > pop_spot(); > } > () = eob(); > #else > EXIT_BLOCK > { > message("foo"); > } > #endif > throw NotImplementedError; >} > test(); > % slsh /tmp/test.sl > Not Implemented > /tmp/test.sl:16:test:Not Implemented > > I expect > % slsh /tmp/test.sl > foo > Not Implemented > /tmp/test.sl:16:test:Not Implemented > > Is this a bug? No. The EXIT_BLOCK will not get executed in the presence of an error. Consider using a `finally' block, e.g., define slsh_main () { try { throw NotImplementedError; } finally { message ("foo"); } } Thanks, --John From p.boekholt at gmail.com Sun Sep 7 12:23:21 2008 From: p.boekholt at gmail.com (Paul Boekholt) Date: Sun Sep 7 12:23:48 2008 Subject: [slang-users] SLruby 0.1.1 Message-ID: Hi, SLruby 0.1.1 is out. - Added support for passing longs, ulongs, llongs and ullongs to Ruby Get it from http://www.cheesit.com/downloads/slang/slruby.html From davis at space.mit.edu Sun Sep 7 23:10:39 2008 From: davis at space.mit.edu (John E. Davis) Date: Sun Sep 7 23:10:55 2008 Subject: [slang-users] slang 2.1.4 released Message-ID: <200809072310.m87NAdKb015592@aluche.mit.edu> Version 2.1.4 of the slang library has been released. Pointers to the source code may be found at . This release consists primarily of bug fixes and interpreter speed improvements, and is binary compatible with previous version 2 releases. A detailed list of changes is appended below. Enjoy, --John Changes since 2.1.3 1. src/slang.c: The identifier syntax was not being checked for symbols added to the global namespace. 2. slsh/slsh.c: If ENV_SLSH_PATH is undefined, set it to SLSH_PATH 3. */mkfiles/*: Modified the various makefile.all files to facilitate mingw32 builds. Read INSTALL.pc for quick-start. 4. mkfiles/install.sl: Added a function to install the slang docs 5. src/slvideo.c: #define UNICODE so that wide-character functions are used instead of byte functions. Also codepage set to 65001 in unicode mode. 6. src/slvideo.c: Added SLtt_is_utf8_mode. 7. src/sltermin.c: Added support for new ncurses hex-encoded terminfo directories. 8. slsh/lib/tm/cmdopt.tm: Missing commas in the documentation for cmdopt_add. (Doug Burke). 9. src/slarrmisc.inc: Changed inner-product code to use block arrays to be more cache friendly. Since the block size is cpu-dependent, __get/set_innerprod_block_size functions have been added. The default value is controlled by a variable in src/sllimits.h. 10. modules/termios-module.c: Added additional termios constants (Laurent Perez). 11. src/slarray.c: Better optimization when indexing arrays with ranges. 12. src/slsignal.c: If SLsystem fails, set the interpreter's errno value accordingly. 13. modules/rand-module.c: A uniform random number generator module, which also provides generators for some well-known distributions. 14. src/*.c: Changed field name for SLang_Object_Type.data_type to o_data_type. 15. src/slang.c: Optimization tweaks to improved performance for small arrays and indexing via scalar indices. 16. doc/tm/rtl/stack.tm: Typos in the example for __pop_list corrected (Doug Burke). 17. src/slang.c: Improved optimizations for scalar arithmetic operations. 18. src/slarray.c: slices such as A[*,[0:-1],*] of multi-dimensional arrays were producing single dimension ones. 19. src/sltoken.c: Changed the semantics of the SLang_set_verbose_loading function. Previously this function accepted a zero or non-zero value to disable or enable loading messages for .sl files. Now this integer value is a bitmapped one: If bit 0 is set, loading messages will be generated for .sl files. If bit 1 is set, messages will be generated for dynamically loaded modules. 20. slsh/slsh.c: Calling slsh with -v will generate loading messages for both modules and slang files. I also created a new slsh-specific intrinsic called set_verbose_loading and bumped the slsh version number. 21. modules/cmaps: Added "ds9b" and "ds9sls" colormaps --- these correspond to analogous colormaps in saotng ds9. 22. utf8/tools/mktables: Characters with general category "Mc" or in the bi-directional category are nolonger flagged as combining characters. 23. utf8/tools/: Updated unicode database from 3.2 to 5.0 and recreated the internal character set tables. 24. src/slsmg.c: If an ambiguous-width unicode line drawing character is double width, then use a single-width alternative (Sugiyama). 25. src/slsignal.c: Call SLang_handle_interrupt when system calls are interrupted. 26. src/slarray.c: Speed improvements when transferring elements from one array to another via range indices, e.g., a = b[[1:9]]; 27. src/slarrfun.c: transpose of multi-dim non-scalar arrays was using unitialized memory. 28. src/slarray.c: Improved speed of binary arithmetic of range arrays. 29. src/slstd.c: atoi, atof, atol, atoll, and integer now accept an array arguments. 30. demo/pager.c: args swapped in call to memset (Dave Jones davej at redhat) 31. src/slstring.c: Move last used string in the hash table to the top if it is more than a few deep. 32. slsh/doc/tm/slsh.1: Added a small section to the slsh man page about customizing the readline environment. 33. slsh/etc/slsh.rc: changed dir_exists from static to private 34. src/slposio.c: The low level read/write functions should not be restarted when errno is EAGAIN. 35. src/sltoken.c: When run in verbose mode, SLns_load_file will display the name of the namespace the file is being loaded into when the namespace is not the Global one. 36. slsh/lib/require.sl: If the "feature" is a filename, then automatically "provide" that feature. 37. slsh/lib/tm/require.tm: Fixed the typos for the require function. 38. src/slstrops.c: Until `|' is supported in REs, glob_to_regexp cannot be made to produce a single RE that does not match leading dots. Hence, the glob expression "*X" will match ".X". 39. slsh/lib/glob.sl: Changed to compensate for modification to glob_to_regexp. That is, glob("*X") will not match the file ".X", which preserves the bahavior of the glob function. 40. src/slcommon.c: On win32 systems, if the codepage is 65001, then use UTF-8 mode (Thomas Wiegner). 41. src/slarray.c: Trivial change to avoid a warning in gcc about the possible use of an uninitialized variable. 42. slsh/slsh.c: Added -q, --quiet command line option to inhibit the printing of the startup messages. 43. slsh/lib/print.sl: Added pager[=val] and nopager qualifiers to the print function. Also if printing a single structure, each field will appear on a separate line. 44. src/slstrops.c, src/slbstr.c: Added count_char/byte_occurances function to count the number of occurances of a specific character or byte in a string. 45. src/slparse.c: &if was causing a SEGV. 46. src/slstd.c: Added get_float_format intrinsic. 47. doc/tm/Makefile: Added rules to make cref.pdf 48. slsh/lib/print.sl: Updated the usage message for the print function. 49. src/slang.h: Added __attribute_(format(printf)) to SLsnprintf prototype. 50. src/*.c: Function prototypes were changed from, e.g., char *SLang_create_slstring (char *); to char *SLang_create_slstring (SLFUTURE_CONST char *); where SLFUTURE_CONST is defined to have no value. As a result, these changes has no effect at present but will in a future version (slang-3) where SLFUTURE_CONST will be defined to be `const'. The use of `const' now would constitute a major API change, which is not permitted until a new major version is released. 51. src/slmisc.c: SLFUTURE_CONST added to SLextract_list_element prototype. 52. src/slang.h: Added SLFUTURE_CONST to arg_type field of SLcmd_Cmd_Type object. 53. src/slarith.c: The return value of fmod was being truncated to single precision. 54. doc/tm/cslang.tm: COLORTERM was used instead of COLORFGBG (Nathan Stratton Treadway). 55. configure,*/Makefile.in: Haiku systems do not require -lm. -lm was replaced */Makefile.in by @M_LIB@ which is not set from the configure script. (Scott McCreary) 56. src/slutty.c,src/slidsply.c: More Haiku-specific patches from Scott McCreary. 57. mkfiles/makefile.m32: Made changes to work with recent versions of mingw32 and added a silly hack to work-around CMD.EXE interpretation of '=' as whitespace on the command line. 58. doc/tm/rtl/rline.tm: New file containing documentation for intrinsic functions dealing with the slang readline interface. 59. slsh/lib/print.sl: If a string is passed as a file descriptor to the print function, then regard the string as a filename. 60. src/Makefile.in: Added _slang.h and sllimits.h as a global dependency. 61. slsh/lib/tm/print.tm: Documented the slsh print function. 62. slsh/lib/print.sl: Rewrote and simplified the code that prints to the various output "devices" by using a device-object. 63. autoconf/Makefile.in: Added src/Makefile.in as a dependency. From joerg at alea.gnuu.de Mon Sep 8 08:51:00 2008 From: joerg at alea.gnuu.de (=?UTF-8?Q?J=C3=B6rg?= Sommer) Date: Tue Sep 9 08:50:25 2008 Subject: [slang-users] Re: EXIT_BLOCK not executed on Error References: <200809070020.m870KwZi013066@aluche.mit.edu> Message-ID: Hallo John, "John E. Davis" wrote: > On Sat, 6 Sep 2008 20:17:38 +0000 (UTC), J?rg Sommer > wrote: >> I expect this code prints ?foo? and the error message, but it prints only >> the error message. >> >> % cat /tmp/test.sl >> define test() >>{ >> #ifexists push_spot >> push_spot(); >> EXIT_BLOCK >> { >> pop_spot(); >> } >> () = eob(); >> #else >> EXIT_BLOCK >> { >> message("foo"); >> } >> #endif >> throw NotImplementedError; >>} >> test(); >> % slsh /tmp/test.sl >> Not Implemented >> /tmp/test.sl:16:test:Not Implemented >> >> I expect >> % slsh /tmp/test.sl >> foo >> Not Implemented >> /tmp/test.sl:16:test:Not Implemented >> >> Is this a bug? > > No. The EXIT_BLOCK will not get executed in the presence of an error. Said. :( I've used it, because I save a level of indentation. Bye, J?rg. -- Der Wille und nicht die Gabe macht den Geber. From guver.tolga at gmail.com Tue Sep 16 21:28:52 2008 From: guver.tolga at gmail.com (Tolga Guver) Date: Tue Sep 16 21:30:00 2008 Subject: [slang-users] goto statement in slang Message-ID: <48D02514.2000307@gmail.com> Hi, I am a newcomer to slang, I have number of scripts written in IDL and want to convert them into s-lang scripts to be able to use within the ISIS (Interactive Spectral Interpretation System) software. I was wondering if there is anything like a goto statement in IDL. I saw in the mailing archive (http://mailman.jedsoft.org/pipermail/slang-users-l/2007.txt) that someone used something like SLang_verror (SL_MALLOC_ERROR, "Cannot Create ARRAY for Attributes!! " ) ; goto attribute_error ; } if (-1 == SLang_push_array (at, 1)) { SLang_verror (SL_INTRIN_ERROR, "Cannot Push Attribute Array on Stack !! " ) ; goto attribute_error ; } return; attribute_error: but when i tried a similar expression i get an error telling goto is undefined. best, tolga -- ====================== Tolga Guver www.physics.arizona.edu/~tolga Steward Observatory 933 N Cherry Ave., Rm. N340 Tucson AZ 85721-0065 From davis at space.mit.edu Tue Sep 16 22:26:02 2008 From: davis at space.mit.edu (John E. Davis) Date: Tue Sep 16 22:26:57 2008 Subject: [slang-users] goto statement in slang In-Reply-To: <48D02514.2000307@gmail.com> References: <48D02514.2000307@gmail.com> Message-ID: <200809162226.m8GMQ2gR029430@aluche.mit.edu> Tolga Guver wrote: > I was wondering if there is anything like a goto statement in IDL. No. There are other control mechanisms such as EXIT_BLOCK that may be used but none are equivalent to the goto statement. > I saw in the mailing archive > (http://mailman.jedsoft.org/pipermail/slang-users-l/2007.txt) that > someone used something like > > SLang_verror (SL_MALLOC_ERROR, "Cannot Create ARRAY for Attributes!! " ) ; > goto attribute_error ; [...] This is a C code fragment, not slang. If you post a code fragment that you are trying to convert, I may be able to suggest something. If your question is more isis-specific, you may want to post to that list. Thanks, --John From joerg at alea.gnuu.de Wed Sep 17 10:11:16 2008 From: joerg at alea.gnuu.de (=?UTF-8?Q?J=C3=B6rg?= Sommer) Date: Wed Sep 17 10:25:09 2008 Subject: [slang-users] Re: goto statement in slang References: <48D02514.2000307@gmail.com> <200809162226.m8GMQ2gR029430@aluche.mit.edu> Message-ID: Hallo John, "John E. Davis" wrote: > Tolga Guver wrote: >> I was wondering if there is anything like a goto statement in IDL. > > No. There are other control mechanisms such as EXIT_BLOCK that may > be used but none are equivalent to the goto statement. As we all know goto is evil, I expect you never will implement it. But what about break and continue with an optional level as in shell. forever { while (1) { break 2; } } Bye, J?rg. -- Die meisten Menschen wollen lieber durch Lob ruiniert als durch Kritik gerettet werden. From davis at space.mit.edu Wed Sep 17 13:31:15 2008 From: davis at space.mit.edu (John E. Davis) Date: Wed Sep 17 13:32:11 2008 Subject: [slang-users] Re: goto statement in slang In-Reply-To: References: <48D02514.2000307@gmail.com> <200809162226.m8GMQ2gR029430@aluche.mit.edu> Message-ID: <200809171331.m8HDVF6U016113@aluche.mit.edu> J?rg Sommer wrote: > As we all know goto is evil, I expect you never will implement it. But I used to think it was evil when I started writing code. I was very proud of the fact that my first version of `most` did not use "goto". For the second and third rewrites of `most`, I replaced the crud that was necessary in the various looping statements to avoid the use of "goto" with "goto" and the result was much cleaner and understandable code. Now I use "goto" when I feel that its use adds clarity to the code, and I feel that those who oppose its use are naive. With that said, I have no intentions to add it to slang and would rather add richer control statements, such as the "then" clause that was added to the looping statements of slang-2.1. > what about break and continue with an optional level as in shell. I have thought about that for slang-2.2, but I will make no promises about it yet. Thanks, --John From joerg at alea.gnuu.de Wed Sep 17 19:45:41 2008 From: joerg at alea.gnuu.de (=?UTF-8?Q?J=C3=B6rg?= Sommer) Date: Wed Sep 17 20:57:20 2008 Subject: [slang-users] Re: goto statement in slang References: <48D02514.2000307@gmail.com> <200809162226.m8GMQ2gR029430@aluche.mit.edu> <200809171331.m8HDVF6U016113@aluche.mit.edu> Message-ID: Hello John, "John E. Davis" wrote: > J?rg Sommer wrote: >> As we all know goto is evil, I expect you never will implement it. But I've forgot to put a smiley here. > I used to think it was evil when I started writing code. I was very > proud of the fact that my first version of `most` did not use "goto". > For the second and third rewrites of `most`, I replaced the crud that > was necessary in the various looping statements to avoid the use of > "goto" with "goto" and the result was much cleaner and understandable > code. Now I use "goto" when I feel that its use adds clarity to the > code, and I feel that those who oppose its use are naive. That's my opinion, too. If it's used advised, it makes the code more readable. >> what about break and continue with an optional level as in shell. > > I have thought about that for slang-2.2, but I will make no promises > about it yet. That would be nice, but decide yourself. BTW: The short forms && and || of andelse resp. orelse are really handy. Bye, J?rg. -- Gienger's Law (http://www.bruhaha.de/laws.html): Die Wichtigkeit eines Newspostings im Usenet ist reziprok zur Anzahl der enthaltenenen, kumulierten Ausrufungszeichen. From laurent.perez at unicaen.fr Thu Sep 18 15:34:10 2008 From: laurent.perez at unicaen.fr (Laurent Perez) Date: Thu Sep 18 15:35:35 2008 Subject: [slang-users] Re: goto statement in slang In-Reply-To: <200809171331.m8HDVF6U016113@aluche.mit.edu> References: <48D02514.2000307@gmail.com> <200809162226.m8GMQ2gR029430@aluche.mit.edu> <200809171331.m8HDVF6U016113@aluche.mit.edu> Message-ID: <20080918153410.GC2063@unicaen.fr> I'm glad to see that we will be at least 3 in hell. Laurent. From p.boekholt at gmail.com Mon Oct 6 18:36:58 2008 From: p.boekholt at gmail.com (Paul Boekholt) Date: Mon Oct 6 18:37:27 2008 Subject: [slang-users] slruby 0.1.2 Message-ID: Hi, SLruby 0.1.2 is out. 1. slruby.sl: SLang.method_missing was defining instance methods instead of module methods 2. rb_complete.rb: added instance method completion for "Foo.new.b" cases 3. slruby.sl: Added instance method_missing function. Get it from http://www.cheesit.com/downloads/slang/slruby.html From joerg at alea.gnuu.de Sat Dec 6 23:08:09 2008 From: joerg at alea.gnuu.de (=?UTF-8?Q?J=C3=B6rg?= Sommer) Date: Sat Dec 6 23:23:16 2008 Subject: [slang-users] Support for assertions? Message-ID: Hi John, do you plan to add support for assertion? I would like to write something like assert(a == 4) and if it is false I want to get an AssertError with the message ?Assertion failed: a == 4??or something this way. I can't solve it easily with a function, because a function gets the value of ?a == 4? and not the expression. Using eval in the assert function might not work, because a might be a local variable in the calling function. It would also be nice, if assert() has a second argument like throw to give a better message for the AssertionError. I can't estimate the ressource usage of such a function. Maybe it would be useful to globally or locally enable or disable this function. While developping I can enable assert and catch such errors, but for production I can disable it and S?Lang skips these commands. What do you think, John? Bye, J?rg. -- Der Pessimist ist jemand, der vorzeitig die Wahrheit erz?hlt. (Cyrano de Bergerac) From davis at space.mit.edu Sun Dec 7 05:11:54 2008 From: davis at space.mit.edu (John E. Davis) Date: Sun Dec 7 05:12:19 2008 Subject: [slang-users] Support for assertions? In-Reply-To: References: Message-ID: <200812070511.mB75BsEU015745@aluche.mit.edu> On Sat, 6 Dec 2008 23:08:09 +0000 (UTC), J?rg Sommer wrote: > do you plan to add support for assertion? I would like to write something > like assert(a == 4) and if it is false I want to get an AssertError with > the message ?Assertion failed: a == 4??or something this way. I had not planned on it but I will think about it for 2.2. > I can't solve it easily with a function, because a function gets the > value of ?a == 4? and not the expression. Using eval in the assert > function might not work, because a might be a local variable in the > calling function. The following (convoluted) function might work. You would use it as in the following example: define slsh_main () { variable foo = 1; assert ("foo==2"); } define assert(expr) { variable info = _get_frame_info (-1); variable localvars = info.locals; variable a = Assoc_Type[]; foreach (localvars) { variable lvar = (); try { a[lvar] = _get_frame_variable (-1, lvar); } catch VariableUninitializedError; } variable inited_vars = assoc_get_keys (a); variable uninited_vars = String_Type[0]; foreach (localvars) { lvar = (); if (assoc_key_exists (a, lvar)) continue; uninited_vars = [uninited_vars, lvar]; } if (length (uninited_vars)) uninited_vars = strcat ("variable ", strjoin (uninited_vars, ","), ";"); else uninited_vars = ""; variable fmt = "private define %s (%s) { %s %s;}"; variable dummy = "__assert_internal_function"; variable fun = sprintf (fmt, dummy, strjoin (inited_vars, ","), uninited_vars, expr); eval ("_use_frame_namespace(-1); $fun"$); foreach lvar (inited_vars) { a[lvar]; } ifnot (eval ("_use_frame_namespace(-1); $dummy;"$)) { throw RunTimeError, sprintf ("Assertion failed: %s at %S:%S", expr, info.file, info.line); } } Thanks, --John From joerg at alea.gnuu.de Sun Dec 7 15:05:51 2008 From: joerg at alea.gnuu.de (=?UTF-8?Q?J=C3=B6rg?= Sommer) Date: Sun Dec 7 15:09:29 2008 Subject: [slang-users] Re: Support for assertions? References: <200812070511.mB75BsEU015745@aluche.mit.edu> Message-ID: Hallo John, "John E. Davis" wrote: > On Sat, 6 Dec 2008 23:08:09 +0000 (UTC), J?rg Sommer > wrote: >> I can't solve it easily with a function, because a function gets the >> value of ?a == 4? and not the expression. Using eval in the assert >> function might not work, because a might be a local variable in the >> calling function. > > The following (convoluted) function might work. You would use it as > in the following example: Howly moly. It's really impressive to see the power of S?Lang. Index: doc/tm/rtl/debug.tm =================================================================== --- doc/tm/rtl/debug.tm (Revision 282) +++ doc/tm/rtl/debug.tm (Arbeitskopie) @@ -232,3 +232,43 @@ \seealso{_slangtrace, _traceback} \done +\function{_get_frame_info} +\synopsis{Returns informations about a stack frame} +\usage{Struct_Type _get_frame_info (Integer_Type depth)} +\description + \ifun{_get_frame_info} returns a structure with informations about the + stack from of depth \svar{depth}. The structue contains the following + fields: + * file: The file that contains the code of the stack frame. + * line: The line in the file the stack frame is in. + * function: the name of the function containing the code of the stack + frame, might be NULL if the code isn't inside of a function + * locals: Array of String_Type containing the names of variables local + to the stack frame. It might be NULL if the stack frame doesn't + belong to a function. + * namespace: The namespace the code of this stack frame is in. +\done + +\function{_get_frame_variable} +\synopsis{Returns the value of a variable as seen from the stack frame} +\usage{Any_Type _get_frame_variable (Integer_Type depth, String_Type name)} +\description + This function returns value of the variable \svar{name} in the stack + frame at depth \svar{depth}. This might not only a local variable but + also variables from outer scopes, e.g. a variable private of the + namespace. + + If no variable with this name is found an UndefinedNameError is + thrown and if the variable is not initialized an + VariableUninitializedError is thrown. +\done + +\function{_use_frame_namespace} +\synopsis{Selects the namespace of a stack frame} +\usage{_use_frame_namespace (Integer_Type depth)} +\description + This function sets the namespace to the one belonging to the stack + frame at depth \svar{depth}. It's approximately the same as + + use_namespace(_get_frame_info(depth).namespace) +\done Index: slsh/lib/require.sl =================================================================== --- slsh/lib/require.sl (Revision 282) +++ slsh/lib/require.sl (Arbeitskopie) @@ -28,6 +28,44 @@ Features[f] = 1; } +%!%+ +%\function{require} +%\synopsis{Make sure a feature is present, and load it if not} +%\usage{require (feature [,namespace [,file]]) +%#v+ +% String_Type feature, namespace, file; +%#v- +%\description +% The \sfun{require} function ensures that a specified "feature" is present. +% If the feature is not present, the \sfun{require} function will attempt to +% load the feature from a file. If the \exmp{namespace} argument is present +% and non-NULL, the specified namespace will be used. The default is to use +% the current non-anonymous namespace. If called with three arguments, the +% feature will be loaded from the file specified by the third argument +% if it does not already exist in the namespace. Otherwise, the feature +% will be loaded from a file given by the name of the feature, with +% ".sl" appended. +% +% If after loading the file, if the feature is not present, +% a warning message will be issued. +%\examples +%#v+ +% require ("histogram"); +% require ("histogram", "foo"); +% require ("histogram", "foo", "/home/bob/hist.sl"); +% require ("histogram", , "/home/bob/hist.sl"); +%#v- +%\notes +% "feature" is an abstract quantity that is undefined here. +% +% A popular use of the \sfun{require} function is to ensure that a specified +% file has already been loaded. In this case, the feature is the +% filename itself. The advantage of using this mechanism over using +% \ifun{evalfile} is that if the file has already been loaded, \sfun{require} +% will not re-load it. For this to work, the file must indicate that it +% provides the feature via the \sfun{provide} function. +%\seealso{provide, _featurep, evalfile} +%!%- define require () { variable feat, file; Bye, J?rg. -- Objektivit?t ist die Wahnvorstellung, Beobachtungen k?nnten ohne Beobachter gemacht werden ? Heinz v. Foerster From michal-lists at vpnet.cz Sun Dec 21 20:35:18 2008 From: michal-lists at vpnet.cz (Michal Ratajsky) Date: Sun Dec 21 20:36:25 2008 Subject: [slang-users] slcurses and utf-8 Message-ID: <494EA886.7060408@vpnet.cz> Hi s-lang people, I've been trying to figure out why I'm having broken UTF-8 in cfdisk on my Ubuntu box. I found out it is compiled with slang-curses support and does not explicitly enable UTF-8 support in slang, thus it does not work. I believe this should be fixed in slang rather than the application to be more compatible with ncurses. What do you think? Thanks, Michal -------------- next part -------------- A non-text attachment was scrubbed... Name: slang-slcurses-enable-utf8.patch Type: text/x-patch Size: 389 bytes Desc: not available Url : http://mailman.jedsoft.org/pipermail/slang-users-l/attachments/20081221/364dbbe0/slang-slcurses-enable-utf8.bin From davis at space.mit.edu Sun Dec 21 21:30:58 2008 From: davis at space.mit.edu (John E. Davis) Date: Sun Dec 21 21:31:22 2008 Subject: [slang-users] slcurses and utf-8 In-Reply-To: <494EA886.7060408@vpnet.cz> References: <494EA886.7060408@vpnet.cz> Message-ID: <200812212130.mBLLUwoO023383@aluche.mit.edu> Michal Ratajsky wrote: > I've been trying to figure out why I'm having broken UTF-8 in cfdisk on > my Ubuntu box. I found out it is compiled with slang-curses support and > does not explicitly enable UTF-8 support in slang, thus it does not > work. I believe this should be fixed in slang rather than the > application to be more compatible with ncurses. What do you think? You patch has been added to pre2.2.0-26. Thanks, --John