more enhancements for the lib

This commit is contained in:
Andreas Rumpf 2010-02-08 22:07:45 +01:00
commit 44ed48ffa6
17 changed files with 65591 additions and 55 deletions

View file

@ -262,15 +262,16 @@ table.footnote {border-left: solid 1px black;margin-left: 1px }
table.docutils td, table.docutils th, table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {padding-left: 0.5em;padding-right: 0.5em; table.docinfo td, table.docinfo th {padding-left: 0.5em;padding-right: 0.5em;
vertical-align: top; border-bottom:1px solid #9D9D9D; color: #4d4d4d} vertical-align: top;}
table.docutils td, table.docutils th { border-bottom:1px solid #9D9D9D; color: #4d4d4d}
table.docutils td:hover, table.docinfo td:hover {color: #000000} table.docutils td:hover, table.docinfo td:hover {color: #000000}
table.docutils th.field-name, table.docinfo th.docinfo-name { table.docutils th.field-name, table.docinfo th.docinfo-name {
font-weight: bold;text-align: left;white-space: nowrap;padding-left: 0 } font-weight: bold;text-align: left;white-space: nowrap;padding-left: 0 }
table.docutils th, table.docinfo th table.docutils th
{ {
color: black; color: black;
font-weight:normal; font-weight:normal;

View file

@ -67,6 +67,8 @@ String handling
Ropes can represent very long strings efficiently; especially concatenation Ropes can represent very long strings efficiently; especially concatenation
is done in O(1) instead of O(n). is done in O(1) instead of O(n).
* `unidecode <unidecode.html>`_
Generic Operating System Services Generic Operating System Services
--------------------------------- ---------------------------------
@ -345,3 +347,6 @@ not contained in the distribution. You can then find them on the website.
* `libzip <libzip.html>`_ * `libzip <libzip.html>`_
Interface to the `lib zip <http://www.nih.at/libzip/index.html>`_ library by Interface to the `lib zip <http://www.nih.at/libzip/index.html>`_ library by
Dieter Baron and Thomas Klausner. Dieter Baron and Thomas Klausner.
* `iup <iup.html>`_
Wrapper of the IUP GUI library.

View file

@ -186,9 +186,6 @@ Index
* `system.html#343 <system.html#343>`_ * `system.html#343 <system.html#343>`_
* `system.html#344 <system.html#344>`_ * `system.html#344 <system.html#344>`_
`<=%`:idx:
`unicode.html#103 <unicode.html#103>`_
`<=%`:idx: `<=%`:idx:
* `system.html#303 <system.html#303>`_ * `system.html#303 <system.html#303>`_
* `system.html#304 <system.html#304>`_ * `system.html#304 <system.html#304>`_
@ -196,6 +193,9 @@ Index
* `system.html#306 <system.html#306>`_ * `system.html#306 <system.html#306>`_
* `system.html#307 <system.html#307>`_ * `system.html#307 <system.html#307>`_
`<=%`:idx:
`unicode.html#103 <unicode.html#103>`_
`==`:idx: `==`:idx:
* `md5.html#107 <md5.html#107>`_ * `md5.html#107 <md5.html#107>`_
* `system.html#258 <system.html#258>`_ * `system.html#258 <system.html#258>`_
@ -247,18 +247,18 @@ Index
`[]`:idx: `[]`:idx:
`ropes.html#115 <ropes.html#115>`_ `ropes.html#115 <ropes.html#115>`_
`[]`:idx:
`macros.html#112 <macros.html#112>`_
`[]`:idx: `[]`:idx:
`strtabs.html#107 <strtabs.html#107>`_ `strtabs.html#107 <strtabs.html#107>`_
`[]=`:idx: `[]`:idx:
`macros.html#113 <macros.html#113>`_ `macros.html#112 <macros.html#112>`_
`[]=`:idx: `[]=`:idx:
`strtabs.html#106 <strtabs.html#106>`_ `strtabs.html#106 <strtabs.html#106>`_
`[]=`:idx:
`macros.html#113 <macros.html#113>`_
`[ESC]`:idx: `[ESC]`:idx:
`manual.html#134 <manual.html#134>`_ `manual.html#134 <manual.html#134>`_
@ -1260,7 +1260,7 @@ Index
`manual.html#222 <manual.html#222>`_ `manual.html#222 <manual.html#222>`_
`downloadFile`:idx: `downloadFile`:idx:
`httpclient.html#111 <httpclient.html#111>`_ `httpclient.html#110 <httpclient.html#110>`_
`dt`:idx: `dt`:idx:
`xmlgen.html#128 <xmlgen.html#128>`_ `xmlgen.html#128 <xmlgen.html#128>`_
@ -1338,7 +1338,7 @@ Index
* `system.html#165 <system.html#165>`_ * `system.html#165 <system.html#165>`_
`EHttpRequestErr`:idx: `EHttpRequestErr`:idx:
`httpclient.html#104 <httpclient.html#104>`_ `httpclient.html#103 <httpclient.html#103>`_
`EInvalidCsv`:idx: `EInvalidCsv`:idx:
`parsecsv.html#105 <parsecsv.html#105>`_ `parsecsv.html#105 <parsecsv.html#105>`_
@ -1362,7 +1362,7 @@ Index
`pegs.html#150 <pegs.html#150>`_ `pegs.html#150 <pegs.html#150>`_
`EInvalidProtocol`:idx: `EInvalidProtocol`:idx:
`httpclient.html#103 <httpclient.html#103>`_ `httpclient.html#102 <httpclient.html#102>`_
`EInvalidRegEx`:idx: `EInvalidRegEx`:idx:
`regexprs.html#104 <regexprs.html#104>`_ `regexprs.html#104 <regexprs.html#104>`_
@ -1409,12 +1409,12 @@ Index
`enum_cursor_type`:idx: `enum_cursor_type`:idx:
`mysql.html#237 <mysql.html#237>`_ `mysql.html#237 <mysql.html#237>`_
`enumeration`:idx:
`tut1.html#113 <tut1.html#113>`_
`Enumeration`:idx: `Enumeration`:idx:
`manual.html#155 <manual.html#155>`_ `manual.html#155 <manual.html#155>`_
`enumeration`:idx:
`tut1.html#113 <tut1.html#113>`_
`enum_field_types`:idx: `enum_field_types`:idx:
`mysql.html#202 <mysql.html#202>`_ `mysql.html#202 <mysql.html#202>`_
@ -1817,7 +1817,7 @@ Index
* `tut2.html#109 <tut2.html#109>`_ * `tut2.html#109 <tut2.html#109>`_
`get`:idx: `get`:idx:
`httpclient.html#107 <httpclient.html#107>`_ `httpclient.html#106 <httpclient.html#106>`_
`GetAllRows`:idx: `GetAllRows`:idx:
* `db_postgres.html#111 <db_postgres.html#111>`_ * `db_postgres.html#111 <db_postgres.html#111>`_
@ -1843,7 +1843,7 @@ Index
`os.html#167 <os.html#167>`_ `os.html#167 <os.html#167>`_
`getContent`:idx: `getContent`:idx:
`httpclient.html#108 <httpclient.html#108>`_ `httpclient.html#107 <httpclient.html#107>`_
`getContentLength`:idx: `getContentLength`:idx:
`cgi.html#111 <cgi.html#111>`_ `cgi.html#111 <cgi.html#111>`_
@ -1897,9 +1897,6 @@ Index
`getGMTime`:idx: `getGMTime`:idx:
`times.html#107 <times.html#107>`_ `times.html#107 <times.html#107>`_
`getHeaderValue`:idx:
`httpclient.html#105 <httpclient.html#105>`_
`getHomeDir`:idx: `getHomeDir`:idx:
`os.html#166 <os.html#166>`_ `os.html#166 <os.html#166>`_
@ -2156,12 +2153,12 @@ Index
`ident=`:idx: `ident=`:idx:
`macros.html#132 <macros.html#132>`_ `macros.html#132 <macros.html#132>`_
`IdentChars`:idx:
`strutils.html#105 <strutils.html#105>`_
`identChars`:idx: `identChars`:idx:
`pegs.html#128 <pegs.html#128>`_ `pegs.html#128 <pegs.html#128>`_
`IdentChars`:idx:
`strutils.html#105 <strutils.html#105>`_
`identifier`:idx: `identifier`:idx:
`manual.html#105 <manual.html#105>`_ `manual.html#105 <manual.html#105>`_
@ -2379,12 +2376,12 @@ Index
* `macros.html#118 <macros.html#118>`_ * `macros.html#118 <macros.html#118>`_
* `ropes.html#103 <ropes.html#103>`_ * `ropes.html#103 <ropes.html#103>`_
`Letters`:idx:
`strutils.html#103 <strutils.html#103>`_
`letters`:idx: `letters`:idx:
`pegs.html#125 <pegs.html#125>`_ `pegs.html#125 <pegs.html#125>`_
`Letters`:idx:
`strutils.html#103 <strutils.html#103>`_
`li`:idx: `li`:idx:
`xmlgen.html#148 <xmlgen.html#148>`_ `xmlgen.html#148 <xmlgen.html#148>`_
@ -3316,6 +3313,12 @@ Index
`ONLY_KILL_QUERY`:idx: `ONLY_KILL_QUERY`:idx:
`mysql.html#189 <mysql.html#189>`_ `mysql.html#189 <mysql.html#189>`_
`Open`:idx:
* `system.html#507 <system.html#507>`_
* `system.html#508 <system.html#508>`_
* `db_postgres.html#118 <db_postgres.html#118>`_
* `db_mysql.html#118 <db_mysql.html#118>`_
`open`:idx: `open`:idx:
* `lexbase.html#104 <lexbase.html#104>`_ * `lexbase.html#104 <lexbase.html#104>`_
* `parsecfg.html#104 <parsecfg.html#104>`_ * `parsecfg.html#104 <parsecfg.html#104>`_
@ -3324,12 +3327,6 @@ Index
* `zipfiles.html#102 <zipfiles.html#102>`_ * `zipfiles.html#102 <zipfiles.html#102>`_
* `httpserver.html#103 <httpserver.html#103>`_ * `httpserver.html#103 <httpserver.html#103>`_
`Open`:idx:
* `system.html#507 <system.html#507>`_
* `system.html#508 <system.html#508>`_
* `db_postgres.html#118 <db_postgres.html#118>`_
* `db_mysql.html#118 <db_mysql.html#118>`_
`openarray`:idx: `openarray`:idx:
* `tut1.html#119 <tut1.html#119>`_ * `tut1.html#119 <tut1.html#119>`_
* `system.html#130 <system.html#130>`_ * `system.html#130 <system.html#130>`_
@ -3364,12 +3361,12 @@ Index
`ord`:idx: `ord`:idx:
`system.html#182 <system.html#182>`_ `system.html#182 <system.html#182>`_
`ordinal`:idx:
`tut1.html#114 <tut1.html#114>`_
`Ordinal`:idx: `Ordinal`:idx:
`system.html#114 <system.html#114>`_ `system.html#114 <system.html#114>`_
`ordinal`:idx:
`tut1.html#114 <tut1.html#114>`_
`Ordinal types`:idx: `Ordinal types`:idx:
`manual.html#142 <manual.html#142>`_ `manual.html#142 <manual.html#142>`_
@ -3409,12 +3406,12 @@ Index
`parseBiggestFloat`:idx: `parseBiggestFloat`:idx:
`parseutils.html#110 <parseutils.html#110>`_ `parseutils.html#110 <parseutils.html#110>`_
`parseBiggestInt`:idx:
`parseutils.html#108 <parseutils.html#108>`_
`ParseBiggestInt`:idx: `ParseBiggestInt`:idx:
`strutils.html#143 <strutils.html#143>`_ `strutils.html#143 <strutils.html#143>`_
`parseBiggestInt`:idx:
`parseutils.html#108 <parseutils.html#108>`_
`parseCmdLine`:idx: `parseCmdLine`:idx:
`os.html#160 <os.html#160>`_ `os.html#160 <os.html#160>`_
@ -3708,10 +3705,10 @@ Index
`system.html#135 <system.html#135>`_ `system.html#135 <system.html#135>`_
`post`:idx: `post`:idx:
`httpclient.html#109 <httpclient.html#109>`_ `httpclient.html#108 <httpclient.html#108>`_
`postContent`:idx: `postContent`:idx:
`httpclient.html#110 <httpclient.html#110>`_ `httpclient.html#109 <httpclient.html#109>`_
`PostgreSQL`:idx: `PostgreSQL`:idx:
`db_postgres.html#101 <db_postgres.html#101>`_ `db_postgres.html#101 <db_postgres.html#101>`_
@ -4074,7 +4071,7 @@ Index
`system.html#379 <system.html#379>`_ `system.html#379 <system.html#379>`_
`request`:idx: `request`:idx:
`httpclient.html#106 <httpclient.html#106>`_ `httpclient.html#105 <httpclient.html#105>`_
`ResetAttributes`:idx: `ResetAttributes`:idx:
`terminal.html#110 <terminal.html#110>`_ `terminal.html#110 <terminal.html#110>`_
@ -5284,8 +5281,8 @@ Index
`thead`:idx: `thead`:idx:
`xmlgen.html#176 <xmlgen.html#176>`_ `xmlgen.html#176 <xmlgen.html#176>`_
`THeader`:idx: `THttpMethod`:idx:
`httpclient.html#102 <httpclient.html#102>`_ `httpclient.html#104 <httpclient.html#104>`_
`TimeInfoToTime`:idx: `TimeInfoToTime`:idx:
`times.html#108 <times.html#108>`_ `times.html#108 <times.html#108>`_

View file

@ -16,6 +16,8 @@
# website for this. # website for this.
# #
{.deadCodeElim: on.}
import import
times times

View file

@ -6,6 +6,8 @@
# connection-protocol. # connection-protocol.
# #
{.deadCodeElim: on.}
when defined(windows): when defined(windows):
const const
dllName = "pq.dll" dllName = "pq.dll"

View file

@ -32,6 +32,8 @@
# *********************************************************************** # ***********************************************************************
# #
{.deadCodeElim: on.}
when defined(WIN32): when defined(WIN32):
const const
dllName = "tcl(85|84|83|82|81|80).dll" dllName = "tcl(85|84|83|82|81|80).dll"

View file

@ -43,7 +43,7 @@
## ##
## echo(postContent("http://validator.w3.org/check", headers, body)) ## echo(postContent("http://validator.w3.org/check", headers, body))
import sockets, strutils, parseurl, pegs, parseutils, strtabs import sockets, strutils, parseurl, parseutils, strtabs
type type
TResponse* = tuple[ TResponse* = tuple[
@ -166,20 +166,32 @@ proc parseResponse(s: TSocket): TResponse =
# Parse the version # Parse the version
# Parses the first line of the headers # Parses the first line of the headers
# ``HTTP/1.1`` 200 OK # ``HTTP/1.1`` 200 OK
var L = skipIgnoreCase(d, "HTTP/1.1", i)
var matches: array[0..1, string] if L > 0:
var L = d.matchLen(peg"\i 'HTTP/' {'1.1'/'1.0'} \s+ {(!\n .)*}\n", result.version = "1.1"
matches, i) inc(i, L)
if L < 0: httpError("invalid HTTP header") else:
L = skipIgnoreCase(d, "HTTP/1.0", i)
result.version = matches[0] if L > 0:
result.status = matches[1] result.version = "1.0"
inc(i, L)
else:
httpError("invalid HTTP header")
L = skipWhiteSpace(d, i)
if L <= 0: httpError("invalid HTTP header")
inc(i, L) inc(i, L)
result.status = ""
while d[i] notin {'\C', '\L', '\0'}:
result.status.add(d[i])
inc(i)
if d[i] == '\C': inc(i)
if d[i] == '\L': inc(i)
else: httpError("invalid HTTP header, CR-LF expected")
# Parse the headers # Parse the headers
# Everything after the first line leading up to the body # Everything after the first line leading up to the body
# htype: hvalue # htype: hvalue
result.headers = newStringTable(modeCaseInsensitive) result.headers = newStringTable(modeCaseInsensitive)
while true: while true:
var key = "" var key = ""

26
lib/pure/unidecode/gen.py Normal file
View file

@ -0,0 +1,26 @@
#! usr/bin/env python
# -*- coding: utf-8 -*-
# Generates the unidecode.dat module
# (c) 2010 Andreas Rumpf
from unidecode import unidecode
def main2():
data = []
for x in xrange(128, 0xffff + 1):
u = eval("u'\u%04x'" % x)
val = unidecode(u)
data.append(val)
f = open("unidecode.dat", "wb+")
for d in data:
f.write("%s\n" % d)
f.close()
main2()

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,65 @@
#
#
# Nimrod's Runtime Library
# (c) Copyright 2010 Andreas Rumpf
#
# See the file "copying.txt", included in this
# distribution, for details about the copyright.
#
## This module is based on Python's Unidecode module by Tomaz Solc,
## which in turn is based on the ``Text::Unidecode`` Perl module by
## Sean M. Burke
## (http://search.cpan.org/~sburke/Text-Unidecode-0.04/lib/Text/Unidecode.pm).
##
## It provides a single proc that does Unicode to ASCII transliterations:
## It finds the sequence of ASCII characters that is the closest approximation
## to the Unicode string.
##
## For example, the closest to string "Äußerst" in ASCII is "Ausserst". Some
## information is lost in this transformation, of course, since several Unicode
## strings can be transformed in the same ASCII representation. So this is a
## strictly one-way transformation. However a human reader will probably
## still be able to guess what original string was meant from the context.
##
## This module needs the data file "unidecode.dat" to work, so it has to be
## shipped with the application!
import unicode
proc loadTranslationTable(filename: string): seq[string] =
newSeq(result, 0xffff)
var i = 0
for line in lines(filename):
result[i] = line
inc(i)
var
translationTable: seq[string]
var
datafile* = "unidecode.dat" ## location can be overwritten for deployment
proc unidecode*(s: string): string =
## Finds the sequence of ASCII characters that is the closest approximation
## to the UTF-8 string `s`.
##
## Example:
##
## ..code-block:: nimrod
## unidecode("\x53\x17\x4E\xB0")
##
## Results in: "Bei Jing"
##
result = ""
for r in runes(s):
var c = int(r)
if c <=% 127: add(result, chr(c))
elif c <=% 0xffff:
if isNil(translationTable):
translationTable = loadTranslationTable(datafile)
add(result, translationTable[c-128])
when isMainModule:
echo unidecode("Äußerst")

View file

@ -1,6 +1,6 @@
# #
# Binding for the IUP GUI toolkit # Binding for the IUP GUI toolkit
# (c) 2009 Andreas Rumpf # (c) 2010 Andreas Rumpf
# C header files translated by hand # C header files translated by hand
# Licence of IUP follows: # Licence of IUP follows:
@ -28,6 +28,7 @@
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# **************************************************************************** # ****************************************************************************
{.deadCodeElim: on.}
when defined(windows): when defined(windows):
const dllname = "iup(30|27|26|25|24).dll" const dllname = "iup(30|27|26|25|24).dll"

View file

@ -16,6 +16,8 @@
# website for this. # website for this.
# #
{.deadCodeElim: on.}
import times import times
when defined(windows): when defined(windows):

View file

@ -1,4 +1,6 @@
{.deadCodeElim: on.}
when not defined(ODBCVER): when not defined(ODBCVER):
const const
ODBCVER = 0x0351 ## define ODBC version 3.51 by default ODBCVER = 0x0351 ## define ODBC version 3.51 by default

View file

@ -6,6 +6,8 @@
# connection-protocol. # connection-protocol.
# #
{.deadCodeElim: on.}
when defined(windows): when defined(windows):
const dllName = "pq.dll" const dllName = "pq.dll"
elif defined(macosx): elif defined(macosx):

View file

@ -53,6 +53,8 @@
# Dr. Dietmar Budelsky, 1997-11-17 # Dr. Dietmar Budelsky, 1997-11-17
#************************************************************************ #************************************************************************
{.deadCodeElim: on.}
import import
dynlib dynlib

View file

@ -32,6 +32,8 @@
# *********************************************************************** # ***********************************************************************
# #
{.deadCodeElim: on.}
when defined(WIN32): when defined(WIN32):
const dllName = "tcl(85|84|83|82|81|80).dll" const dllName = "tcl(85|84|83|82|81|80).dll"
elif defined(macosx): elif defined(macosx):

View file

@ -31,7 +31,9 @@ Additions
- Added ``sockets`` module. - Added ``sockets`` module.
- Added ``browsers`` module. - Added ``browsers`` module.
- Added ``httpserver`` module. - Added ``httpserver`` module.
- Added ``httpclient`` module.
- Added ``parseutils`` module. - Added ``parseutils`` module.
- Added ``unidecode`` module.
- Many wrappers now do not contain redundant name prefixes (like ``GTK_``, - Many wrappers now do not contain redundant name prefixes (like ``GTK_``,
``lua``). The new wrappers are available in ``lib/newwrap``. Change ``lua``). The new wrappers are available in ``lib/newwrap``. Change
your configuration file to use these. your configuration file to use these.