upload tizen1.0 source 2.0alpha master 2.0_alpha submit/master/20120920.151008
authorKim Kibum <kb0929.kim@samsung.com>
Sun, 29 Apr 2012 08:01:13 +0000 (17:01 +0900)
committerKim Kibum <kb0929.kim@samsung.com>
Sun, 29 Apr 2012 08:01:13 +0000 (17:01 +0900)
debian/changelog
debian/copyright [new file with mode: 0644]
libiri/parse.c

index a5b4738..7804fa0 100644 (file)
@@ -1,8 +1,26 @@
+libiri (1.2) unstable; urgency=low
+
+  * Optimize OBS (Add the spec file)
+
+  * Git : 165.213.180.234:slp/pkgs/l/libiri
+  * Tag : libiri_1.2
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Wed, 14 Mar 2012 12:48:10 +0900
+
 libiri (1.1) unstable; urgency=low
 
-  * Init changelog
+  * fix bug regarding length of iri
 
-  * Git : pkgs/l/libiri
+  * Git : 165.213.180.234:slp/pkgs/l/libiri
   * Tag : libiri_1.1
 
  -- Yunchan Cho <yunchan.cho@samsung.com>  Wed, 07 Dec 2011 12:36:14 +0900
+
+libiri (1.0) unstable; urgency=low
+
+  * debianized
+
+  * Git : 165.213.180.234:slp/pkgs/l/libiri
+  * Tag : libiri_1.0
+
+ -- Yunchan Cho <yunchan.cho@samsung.com>  Fri, 02 Dec 2011 16:03:15 +0900
diff --git a/debian/copyright b/debian/copyright
new file mode 100644 (file)
index 0000000..88d6d99
--- /dev/null
@@ -0,0 +1,21 @@
+This is libiri, written and maintained by unknown <yunchan.cho@samsung.com>
+on Mon, 29 Nov 2010 13:54:22 +0900.
+
+The original source can always be found at:
+    http://libiri.googlecode.com/svn/trunk/
+
+Copyright:
+    Copyright (c) 2005, 2008 Mo McRoberts.
+
+License:
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following conditions
+    are met:
+    1. Redistributions of source code must retain the above copyright
+       notice, this list of conditions and the following disclaimer.
+    2. Redistributions in binary form must reproduce the above copyright
+       notice, this list of conditions and the following disclaimer in the
+       documentation and/or other materials provided with the distribution.
+    3. The names of the author(s) of this software may not be used to endorse
+       or promote products derived from this software without specific prior
+       written permission.
index fa881e4..ea12de7 100644 (file)
@@ -344,28 +344,82 @@ iri__allocbuf(const char *src, size_t *len)
 {
        size_t sc;
        const char *p, *c;
-       
-       /* Calculate the size of the buffer required to hold a decoded version of
-        * src, including enough breathing space for null bytes.
-        */
-       /* XXX: This is way too much; we need to actually count it */
-       *len = (strlen(src) * 4) + 16;
-       /* Determine how much space we need for the scheme list */
-       if(NULL != (c = strchr(src, ':')))
-       {
-               sc = 1;
-               for(p = src; p < c; p++)
-               {
-                       if(*p == '+')
-                       {
-                               sc++;
-                       }
-               }
-               /* Ensure we can align each element on an 8-byte boundary */
-               *len = (src - c) + 1 + sc + ((sc + 1) * (sizeof(char *) + 7));
-               *len += (7 * 11);
-       }
-    *len = 9999; // FIXME: DIRTY HACK THAT USUALLY WORKS... UNTIL IRI IS NOT TOO LONG
+/*
+       Internal format of IRI structure is very hard to understand at first.
+       The buffer is used to store character strings with every parsed part of
+       IRI, like host, user, auth, path etc. Start of every character string is
+       ALIGNED to ALIGNMENT value and finished with NULL byte.
+       Above that, the buffer is used to keep variable size array of parsed
+       scheme parts. It consist of the array of addresses pointing to starts
+       of scheme parts which are kept as all other characters strings, so are
+       aligned to ALIGMENT and ended with NULL byte.
+       This function calculates approximation of buffer size to store all the
+       data of parser IRI.
+
+       Fully filled buffer with scheme parts looks as follows:
+       0. start of the buffer
+       1. aligned start of the scheme part with added NULL byte
+       2. aligned start of the user part with added NULL byte
+       3. aligned start of the password part with added NULL byte
+       4. aligned start of the array of size schemes_number+1 of pointers that point
+          to consecutive scheme part character strings (last one is NULL)
+          schemes_number is a number of scheme tokens delimited with + sign in
+          scheme part
+       5. schems_number of characters strings of scheme parts each of which
+          aligned and finished with NULL byte.
+       6. aligned start of the host part with added NULL byte
+       7. aligned start of the path part with added NULL byte
+       8. aligned start of the query part with added NULL byte
+       9. aligned start of the anchor part with added NULL byte
+
+       There can be indentified 4 kinds of characters in IRI:
+       - characters which are copied one to one (i.e. letters)
+       - characters which are removed (special characters like comma in scheme)
+       - characters which are replaced with other characers where buffer grows
+         this only happens with scheme part
+       - characters which are replaced with other characers where buffer decreases
+
+       Alighning a pointer in worst case will advance a buffer pointers
+       ALIGNMENT-1 bytes
+
+       Knowing all that we can count an approximation of buffer size which can
+       be trusted that whole parsed IRI content will fit in.
+*/
+
+/* first approximation - all characers will have to be stored in buffer */
+       *len = strlen(src);
+
+/* second approximation - IRI has all possible parts which have to be
+ * aligned to ALIGNMENT and have NULL byte an the end. There are 7 different
+ * parts like that */
+       *len += 7 * (ALIGNMENT-1 + 1);
+
+/* third approximation - we have to make a room for scheme parts array.
+ * Because the array has an aligned array of n + 1 pointers and n
+ * characters strings aligned and NULL byte terminated.
+ */
+    if(NULL != (c = strchr(src, ':')))
+    {
+        sc = 1;
+        for(p = src; p < c; p++)
+        {
+            if(*p == '+')
+            {
+                sc++;
+            }
+        }
+               /* fourth approximation - all characters of scheme part will be stored
+                * in scheme parts tokens */
+               *len += (c - src);
+
+               /* fifth approximation - Ensure we can align each element on an
+                * ALIGNMENT byte boundary and append NULL byte */
+               *len += sc * (ALIGNMENT-1 + 1);
+
+               /* sixth approximation - Ensure we have a room for aligned array
+                * indexes */
+               *len += ALIGNMENT-1 + (sc + 1) * (sizeof(char*)/sizeof(char));
+    }
        return (char *) calloc(1, *len);
 }