conversions are all in; next phase is fixing and making it work.

--- src/gencode.c
+++ src/gencode.c
@@ -1677,6 +1677,9 @@
     fprintf(OUT, "\tderef      P%d, CONSTS, P%d\n", cf_reg.no, cf_reg.no);

     m1_reg I0 = alloc_reg(comp, VAL_INT);
+    INS (M0_SET_IMM, "%I, %d, %d", I0.no, 0, 0);
+    INS (M0_GOTO_CHUNK, "%P, %I", cf_reg.no, I0.no);
+
     fprintf(OUT, "\tset_imm    I%d, 0, 0\n", I0.no);
     fprintf(OUT, "\tgoto_chunk P%d, I%d, x\n", cf_reg.no, I0.no);
     free_reg(comp, I0);
@@ -1708,15 +1711,23 @@
     set_imm  I9,  0,  BCS
     set_ref  PCF, I9, BCS
 */
+    INS (M0_SET_IMM, "%I, %d, %d", I9.no, 0, CHUNK);
+    INS (M0_SET_REF, "%d, %I, %d", PCF, I9.no, CHUNK);
     fprintf(OUT, "\tset_imm   I%d, 0, CHUNK\n", I9.no);
     fprintf(OUT, "\tset_ref   PCF, I%d, CHUNK\n", I9.no);
-
+
+    INS (M0_SET_IMM, "%I, %d, %d", I9.no, 0, CONSTS);
+    INS (M0_SET_REF, "%d, %I, %d", PCF, I9.no, CONSTS);
     fprintf(OUT, "\tset_imm   I%d, 0, CONSTS\n", I9.no);
     fprintf(OUT, "\tset_ref   PCF, I%d, CONSTS\n", I9.no);
-
+
+    INS (M0_SET_IMM, "%I, %d, %d", I9.no, 0, MDS);
+    INS (M0_SET_REF, "%d, %I, %d", PCF, I9.no, MDS);
     fprintf(OUT, "\tset_imm   I%d, 0, MDS\n", I9.no);
     fprintf(OUT, "\tset_ref   PCF, I%d, MDS\n", I9.no);
-
+
+    INS (M0_SET_IMM, "%I, %d, %d", I9.no, 0, BCS);
+    INS (M0_SET_REF, "%d, %I, %d", PCF, I9.no, BCS);
     fprintf(OUT, "\tset_imm   I%d, 0, BCS\n", I9.no);
     fprintf(OUT, "\tset_ref   PCF, I%d, BCS\n", I9.no);

@@ -2328,6 +2339,8 @@
         m1_reg retpc_reg   = alloc_reg(comp, VAL_INT);
         m1_reg retpc_index = alloc_reg(comp, VAL_INT);

+        INS (M0_SET_IMM, "%I, %d, %d", retpc_index.no, 0, RETPC);
+        INS (M0_DEREF,   "%I, %d, %I", retpc_reg.no, PCF, retpc_index.no);
         fprintf(OUT, "\tset_imm    I%d, 0, RETPC\n", retpc_index.no);
         fprintf(OUT, "\tderef      I%d, PCF, I%d\n", retpc_reg.no, retpc_index.no);

@@ -2335,6 +2348,9 @@

         chunk_index = alloc_reg(comp, VAL_INT);

+        INS (M0_SET_IMM, "%I, %d, %d", chunk_index.no, 0, CHUNK);
+        INS (M0_DEREF,   "%I, %d, %I", chunk_index.no, PCF, chunk_index.no);
+        INS (M0_GOTO_CHUNK, "%I, %I", chunk_index.no, retpc_reg.no);
         fprintf(OUT, "\tset_imm    I%d, 0, CHUNK\n", chunk_index.no);
         fprintf(OUT, "\tderef      I%d, PCF, I%d\n", chunk_index.no, chunk_index.no);
         fprintf(OUT, "\tgoto_chunk I%d, I%d, x\n", chunk_index.no, retpc_reg.no);


[security] encode quoting chars in HTML and XML

(affects mod_dirlisting, mod_ssi, mod_status)


Added missing function comments to gholder.c.

--- src/gholder.c
+++ src/gholder.c
@@ -79,6 +79,10 @@
 };
 /* *INDENT-ON* */

+/* Get a panel from the GPanel structure given a module.
+ *
+ * On error, or if not found, NULL is returned.
+ * On success, the panel value is returned. */
 static GPanel *
 panel_lookup (GModule module)
 {


doc: fix trailing spaces in code comments

--- src/libs/elektra/keymeta.c
+++ src/libs/elektra/keymeta.c
@@ -142,15 +142,15 @@
  * @endcode
  *
  * @param key Key whose internal iterator should be rewinded
- *
+ *
  * @retval 0 on success
  * @retval 0 if there is no metadata for that key
  *         (keyNextMeta() will always return 0 in that case)
  * @retval -1 on NULL pointer
- *
- * @since 1.0.0
- * @ingroup keymeta
- *
+ *
+ * @since 1.0.0
+ * @ingroup keymeta
+ *
  * @see keyNextMeta(), keyCurrentMeta() for iterating after rewinding
  * @see ksRewind() KeySet's equivalent function for rewinding
  **/
@@ -180,14 +180,14 @@
  *    use keySetMeta() if you want to delete or change it.
  *
  * @param key the Key object to work with
- *
+ *
  * @return a key containing metadata
  * @retval 0 when the last Key has been reached
  * @retval 0 when Key is a NULL pointer
  *
  * @since 1.0.0
  * @ingroup keymeta
- *
+ *
  * @see ksNext() for pedant in iterator interface of KeySet
  * @see keyRewindMeta() for rewinding the internal iterator
  * @see keyCurrentMeta() for getting the current metadata Key
@@ -213,13 +213,13 @@
  *    use keySetMeta() if you want to delete or change it.
  *
  * @param key Key to get the current metadata from
- *
+ *
  * @return a buffer to the value pointed by @p key's cursor
  * @retval 0 on NULL pointer
- *
- * @since 1.0.0
- * @ingroup keymeta
- *
+ *
+ * @since 1.0.0
+ * @ingroup keymeta
+ *
  * @see keyNextMeta() for getting the next value
  * @see keyRewindMeta() for rewinding the internal iterator
  * @see ksCurrent() KeySets's equivalent function for getting the current Key
@@ -284,16 +284,16 @@
  * @param dest the destination where the metadata should be copied to
  * @param source the key where the metadata should be copied from
  * @param metaName the name of the metadata Key which should be copied
- *
+ *
  * @retval 1 if was successfully copied
  * @retval 0 if the metadata in dest was removed too
  * @retval -1 on null pointers (source or dest)
  * @retval -1 on memory problems
  * @retval -1 if metadata is read-only
- *
- * @since 1.0.0
- * @ingroup keymeta
- *
+ *
+ * @since 1.0.0
+ * @ingroup keymeta
+ *
  * @see keyCopyAllMeta() copies all metadata from @p dest to @p src
  */
 int keyCopyMeta (Key * dest, const Key * source, const char * metaName)
@@ -379,12 +379,12 @@
  *
  * @param dest the destination where the metadata should be copied too
  * @param source the key where the metadata should be copied from
- *
+ *
  * @retval 1 if metadata was successfully copied
  * @retval 0 if source did not have any metadata
  * @retval -1 on null pointer of dest or source
  * @retval -1 on memory problems
- *
+ *
  * @since 1.0.0
  * @ingroup keymeta
  * @see keyCopyMeta() for copying one metadata Key from @p dest to @p source
@@ -415,7 +415,7 @@
 /** Returns the Key for a metadata entry with name @p metaName.
  *
  * You are not allowed to modify the resulting key.
- *
+ *
  * If @p metaName does not start with 'meta:/',
  * it will be prefixed with 'meta:/'.
  *
@@ -430,11 +430,11 @@
  *
  * @param key the Key from which to get metadata
  * @param metaName the name of the meta information you want the Key from.
- *
+ *
  * @return value of meta-information if meta-information is found
  * @retval 0 if key or metaName is NULL
  * @retval 0 if no such metaName is found
- *
+ *
  * @since 1.0.0
  * @ingroup keymeta
  * @see keySetMeta() for setting metadata
@@ -478,21 +478,21 @@
  * @p metaName was inserted already.
  *
  * It will remove a metadata Key if @p newMetaString is 0.
- *
+ *
  * If @p metaName does not start with 'meta:/',
  * it will be prefixed with 'meta:/'.
  *
  * @param key Key whose metadata should be set
  * @param metaName name of the metadata Key that should be set
  * @param newMetaString new value for the metadata Key
- *
+ *
  * @return size (>0) of @p newMetaString if metadata has been
  *         successfully added
  * @retval 0 if the meta-information for metaName was removed
  * @retval -1 if key or metaName is 0
  * @retval -1 if system is out of memory
  * @retval -1 if @p metaName is not a valid metadata name
- *
+ *
  * @since 1.0.0
  * @ingroup keymeta
  * @see keyGetMeta() for getting the value of a metadata Key
@@ -603,11 +603,11 @@
  * @note Adding a key with metadata to the KeySet is an error.
  *
  * @param key the Key from which to get the metadata KeySet
- *
+ *
  * @return the KeySet holding the metadata
  * @retval 0 if the Key is 0
  * @retval 0 if the Key has no metadata
- *
+ *
  * @since 1.0.0
  * @ingroup keymeta
  * @see keySetMeta() for setting a metadata Key


fix slurp(), it needs to read size-1 for the trailing NUL

--- src/general.c
+++ src/general.c
@@ -19,7 +19,8 @@
         if ((fd = open(filename, O_RDONLY)) == -1)
                 return false;

-        int n = read(fd, destination, size);
+        /* We need one byte for the trailing 0 byte */
+        int n = read(fd, destination, size-1);
         if (n != -1)
                 destination[n] = '\0';
         (void)close(fd);


odb_loose: Reword errors

odb_loose: Reword errors

--- src/odb_loose.c
+++ src/odb_loose.c
@@ -452,7 +452,11 @@
 cleanup:
 	finish_inflate(&zs);
 	gitfo_close(fd);
-	return error == GIT_SUCCESS ? GIT_SUCCESS : git__rethrow(error, "Failed to read loose object header");
+
+	if (error < GIT_SUCCESS)
+		return git__throw(error, "Failed to read loose object header. Header is corrupted");
+
+	return GIT_SUCCESS;
 }

 static int locate_object(char *object_location, loose_backend *backend, const git_oid *oid)
@@ -485,11 +489,14 @@

 	assert(backend && oid);

+	raw.len = 0;
+	raw.type = GIT_OBJ_BAD;
+
 	if (locate_object(object_path, (loose_backend *)backend, oid) < 0)
 		return git__throw(GIT_ENOTFOUND, "Failed to read loose backend header. Object not found");

 	if ((error = read_header_loose(&raw, object_path)) < GIT_SUCCESS)
-		return git__rethrow(error, "Failed to read loose backend header");
+		return error;

 	*len_p = raw.len;
 	*type_p = raw.type;


fixed PAGE_LOOP

fixed PAGE_LOOP

--- src/gjalloc.h
+++ src/gjalloc.h
@@ -494,7 +494,7 @@
 /* goto considered harmful */
 #define LOW_PAGE_LOOP2(a, label, C...)	do {			\
     uint32_t __n;						\
-    for (__n = 0; __n < a->allocated; __n++) {			\
+    if (a->pages) for (__n = 0; __n < a->allocated; __n++) {	\
 	ba_p p = a->pages[__n];					\
 	while (p) {						\
 	    ba_p t = p->hchain;					\


Utils.Transform: fix stolen const on MFP

Change-Id: I44ef3bac606a733a81f95472d0ca5bb50ee3bca0
Reviewed-by: Daniel Teske <d8a411aec9a206efedb4d45b75fe8d13f1e2b628@theqtcompany.com>

--- src/libs/utils/algorithm.h
+++ src/libs/utils/algorithm.h
@@ -324,7 +324,7 @@
          typename R,
          typename S>
 Q_REQUIRED_RESULT
-auto transform(const SC &container, R (S::*p)())
+auto transform(const SC &container, R (S::*p)() const)
      -> C<typename RemoveCvAndReference<R>::type>
 {
     return TransformImpl<


Added some color

Added some color

--- src/getback.c
+++ src/getback.c
@@ -30,6 +30,10 @@
 static const double YARDS_IN_MILE = 1760;
 GPoint center;

+GColor approaching;
+GColor receding;
+GColor bg;
+
 const GPathInfo HEAD_PATH_POINTS = {
   3,
   (GPoint []) {
@@ -72,7 +76,7 @@
   gpath_rotate_to(head_path, (TRIG_MAX_ANGLE / 360) * (heading + TRIGANGLE_TO_DEG(orientation)));
   graphics_context_set_fill_color(ctx, GColorBlack);
   graphics_fill_circle(ctx, center, 77);
-  graphics_context_set_fill_color(ctx, GColorWhite);
+  graphics_context_set_fill_color(ctx, bg);
   gpath_draw_filled(ctx, head_path);
   graphics_fill_circle(ctx, center, 49);
   graphics_context_set_fill_color(ctx, GColorBlack);
@@ -163,6 +167,15 @@
   Tuple *dist_tuple = dict_find(iter, DIST_KEY);
   if (dist_tuple) {
     hide_hint();
+    if (dist_tuple->value->int32 > distance) {
+      bg = receding;
+    }
+    else if (dist_tuple->value->int32 < distance) {
+      bg = approaching;
+    }
+    else {
+      bg = GColorWhite;
+    }
     distance = dist_tuple->value->int32;
   }
   if (strcmp(units, "imperial") == 0) {
@@ -305,6 +318,14 @@
       APP_LOG(APP_LOG_LEVEL_WARNING, "Launched from timeline, pin ID: %lu", id);
     }
   #endif
+  #ifdef PBL_COLOR
+    approaching = GColorMalachite;
+    receding = GColorFolly;
+  #else
+    approaching = GColorWhite;
+    receding = GColorWhite;
+  #endif
+  bg = GColorWhite;
   compass_service_set_heading_filter(TRIG_MAX_ANGLE*sensitivity/360);
   compass_service_subscribe(&compass_heading_handler);
   app_message_register_inbox_received(in_received_handler);


Updating comments in odbcshell.c

Updating comments in odbcshell.c

--- src/odbcshell.c
+++ src/odbcshell.c
@@ -176,6 +176,7 @@
    if ((odbcshell_initialize(&cnf)))
       return(1);

+   // processes command line arguments
    while((c = getopt_long(argc, argv, short_opt, long_opt, &opt_index)) != -1)
    {
       switch(c)
@@ -254,12 +255,14 @@
       };
    };

+   // sets default runtime mode
    if (!(cnf->mode))
       cnf->mode = ODBCSHELL_MODE_SHELL;
    if (cnf->mode == ODBCSHELL_MODE_SHELL)
       if (optind < argc)
          cnf->mode = ODBCSHELL_MODE_SCRIPT;

+   // opens default output file
    if ((cnf->dflt_output))
    {
       if ((odbcshell_fopen(cnf, cnf->dflt_output)))
@@ -269,18 +272,21 @@
       };
    };

+   // initializes iODBC/unixODBC library
    if ((odbcshell_odbc_initialize(cnf)))
    {
       odbcshell_free(cnf);
       return(1);
    };

+   // loads ODBC Shell init scripts
    if ((odbcshell_profile(cnf)))
    {
       odbcshell_free(cnf);
       return(1);
    };

+   // starts specified runtime mode
    sts = 0;
    switch(cnf->mode)
    {


Added more logging about space allocation.

--- src/c/heap.c
+++ src/c/heap.c
@@ -102,7 +102,7 @@
   if (next <= space->limit) {
     // Clear the newly allocated memory to a different value, again to make the
     // contents recognizable.
-    printf("%p\n", addr);
+    printf("%p %li %li\n", addr, size, aligned);
     memset(addr, kAllocedHeapMarker, aligned);
     *memory_out = addr;
     space->next_free = next;


re-sync getline.c

re-sync getline.c

--- src/getline.c
+++ src/getline.c
@@ -92,3 +92,28 @@
     return *n=-1;
 }
 #endif
+
+#ifdef WIN32
+I getline(S *s,I*n, FILE *f){ return getdelim(s,n,'\n',f);}
+I getdelim(S *s,I*n, I d, FILE *f) {   //target, current capacity, delimiter, file
+  //unsigned char *q;
+  O("s: %s\n",s); O("sizeof(s): %d\n",sizeof(s));
+  char *q;
+  I w=0;
+  if (!s) {errno = EINVAL; goto error;}
+  if (f->_cnt <= 0) {
+    if (expander(s, 1)) goto error;
+    (*s)[0] = '\0'; return *n=-1;
+  }
+  while ((q = memchr(f->_ptr, d, f->_cnt)) == NULL) {
+    if (appender(s, &w, (S) f->_ptr, f->_cnt)) goto error;
+    goto done;  /* hit EOF */
+  }
+  q++;  /* snarf the delimiter, too */
+  if (appender(s, &w, (S) f->_ptr, q - f->_ptr)) goto error;
+  f->_cnt -= q - f->_ptr;
+  f->_ptr = q;
+  done: (*s)[w] = '\0'; R *n=w;
+  error: R *n=-1;
+}
+#endif


Check for unfound routes after OSRM table request.

--- src/loaders/osrm_wrapper.h
+++ src/loaders/osrm_wrapper.h
@@ -19,6 +19,7 @@
 #ifndef OSRM_WRAPPER_H
 #define OSRM_WRAPPER_H
 #include <vector>
+#include <limits>
 #include <cstring>              // c_str()
 #include<sys/socket.h>          //socket
 #include<arpa/inet.h>           //inet_addr
@@ -189,7 +190,51 @@
     }

     matrix<distance_t> m (matrix_as_vector);
-    m.print();
+    // m.print();
+
+    // Now checking for unfound routes to avoid unexpected behavior
+    // (OSRM raises max value for an int).
+    unsigned m_size = m.size();
+    std::vector<unsigned> nb_unfound_from_loc (m_size, 0);
+    std::vector<unsigned> nb_unfound_to_loc (m_size, 0);
+    distance_t unfound_time
+      = std::numeric_limits<int>::max();
+
+    for(unsigned i = 0; i < m_size; ++i){
+      for(unsigned j = 0; j < m_size; ++j){
+        if(m(i, j) == unfound_time){
+          // Just storing info as we don't know yet which location is
+          // responsible between i and j.
+          ++nb_unfound_from_loc[i];
+          ++nb_unfound_to_loc[j];
+        }
+      }
+    }
+
+    unsigned max_unfound_routes_for_a_loc = 0;
+    index_t error_loc = 0;    // Initial value never actually used.
+    std::string error_direction;
+    // Finding the "worst" location.
+    for(unsigned i = 0; i < m_size; ++i){
+      if(nb_unfound_from_loc[i] > max_unfound_routes_for_a_loc){
+        max_unfound_routes_for_a_loc = nb_unfound_from_loc[i];
+        error_loc = i;
+        error_direction = "from";
+      }
+      if(nb_unfound_to_loc[i] > max_unfound_routes_for_a_loc){
+        max_unfound_routes_for_a_loc = nb_unfound_to_loc[i];
+        error_loc = i;
+        error_direction = "to";
+      }
+    }
+    if(max_unfound_routes_for_a_loc > 0){
+      std::cout << "OSRM has unfound route(s) "
+                << error_direction
+                << " location at index: "
+                << std::to_string(error_loc)
+                << std::endl;
+      exit(0);
+    }

     return m;
   }


Fix incorrect error log in ofp_vrf_route_alloc().

Clearly, this error log was left unchanged when copying the code from
ofp_vlan_alloc().

Signed-off-by: Jere Leppänen <14957520de8d9815e0c353a07fe23c737f0171e9@nokia.com>
Reviewed-by: Sorin Vultureanu <8013ba55f8675034bc2ab0d6c3a1c9650437ca36@enea.com>

--- src/ofp_route.c
+++ src/ofp_route.c
@@ -124,7 +124,7 @@
 	odp_rwlock_write_unlock(&vrf_shm->vrf_mtx);

 	if (rt == NULL) {
-		OFP_ERR("Cannot allocate vlan!");
+		OFP_ERR("Cannot allocate VRF.");
 		return (NULL);
 	}


use the ip4 socket address for ipv4 again

--- src/c/http.c
+++ src/c/http.c
@@ -322,19 +322,27 @@
   exit(0);
 }

+union uw_sockaddr {
+  struct sockaddr sa;
+  struct sockaddr_in ipv4;
+  struct sockaddr_in6 ipv6;
+};
+
 int main(int argc, char *argv[]) {
   // The skeleton for this function comes from Beej's sockets tutorial.
   int sockfd;  // listen on sock_fd
-  struct sockaddr_in6 my_addr;
-  struct sockaddr_in6 their_addr; // connector's address information
+  union uw_sockaddr my_addr;
+  union uw_sockaddr their_addr; // connector's address information
   socklen_t sin_size;
-  int yes = 1, no = 0, uw_port = 8080, nthreads = 1, i, *names, opt;
+  int yes = 1, uw_port = 8080, nthreads = 1, i, *names, opt;
   int recv_timeout_sec = 5;

   signal(SIGINT, sigint);
   signal(SIGPIPE, SIG_IGN);

-  my_addr.sin6_addr = in6addr_any; // auto-fill with my IP
+  // default if not specified: IPv4 with my IP
+  my_addr.sa.sa_family = AF_INET;
+  my_addr.ipv4.sin_addr.s_addr = INADDR_ANY; // auto-fill with my IP

   while ((opt = getopt(argc, argv, "hp:a:A:t:kqT:")) != -1) {
     switch (opt) {
@@ -357,20 +365,17 @@
       break;

     case 'a':
-      {
-        char *buf = alloca(strlen(optarg) + 8);
-        strcpy(buf, "::FFFF:");
-        strcpy(buf + 7, optarg);
-        if (!inet_pton(AF_INET6, buf, &my_addr.sin6_addr)) {
-          fprintf(stderr, "Invalid IPv4 address\n");
-          help(argv[0]);
-          return 1;
-        }
+      my_addr.sa.sa_family = AF_INET;
+      if (!inet_pton(AF_INET, optarg, &my_addr.ipv4.sin_addr)) {
+        fprintf(stderr, "Invalid IPv4 address\n");
+        help(argv[0]);
+        return 1;
       }
       break;

     case 'A':
-      if (!inet_pton(AF_INET6, optarg, &my_addr.sin6_addr)) {
+      my_addr.sa.sa_family = AF_INET6;
+      if (!inet_pton(AF_INET6, optarg, &my_addr.ipv6.sin6_addr)) {
         fprintf(stderr, "Invalid IPv6 address\n");
         help(argv[0]);
         return 1;
@@ -413,7 +418,7 @@

   names = calloc(nthreads, sizeof(int));

-  sockfd = socket(AF_INET6, SOCK_STREAM, 0); // do some error checking!
+  sockfd = socket(my_addr.sa.sa_family, SOCK_STREAM, 0); // do some error checking!

   if (sockfd < 0) {
     fprintf(stderr, "Listener socket creation failed\n");
@@ -425,15 +430,13 @@
     return 1;
   }

-  if (setsockopt(sockfd, IPPROTO_IPV6, IPV6_V6ONLY, &no, sizeof(int)) < 0) {
-    fprintf(stderr, "Listener IPV6_V6ONLY option resetting failed\n");
-    return 1;
-  }
-
-  my_addr.sin6_family = AF_INET6;        // host byte order
-  my_addr.sin6_port = htons(uw_port);    // short, network byte order
-
-  if (bind(sockfd, (struct sockaddr *)&my_addr, sizeof my_addr) < 0) {
+  switch (my_addr.sa.sa_family)
+  {
+  case AF_INET:  my_addr.ipv4.sin_port  = htons(uw_port); break;
+  case AF_INET6: my_addr.ipv6.sin6_port = htons(uw_port); break;
+  }
+
+  if (bind(sockfd, &my_addr.sa, sizeof my_addr) < 0) {
     fprintf(stderr, "Listener socket bind failed\n");
     return 1;
   }
@@ -470,7 +473,7 @@
   }

   while (1) {
-    int new_fd = accept(sockfd, (struct sockaddr *)&their_addr, &sin_size);
+    int new_fd = accept(sockfd, &their_addr.sa, &sin_size);

     if (new_fd < 0) {
       qfprintf(stderr, "Socket accept failed\n");


glsl: Align comments on variables types

glsl: Align comments on variables types

v2:
 * Split from patch to add ir_var_shader_shared (tarceri)

Signed-off-by: Jordan Justen <a79006884ba9cf5f4f7fcbb92a15b208780d8c97@intel.com>
Reviewed-by: Timothy Arceri <5dd83789ef3714029244367ba1ca09f1d7627408@collabora.com>

--- src/glsl/ir.h
+++ src/glsl/ir.h
@@ -322,18 +322,18 @@
  * Variable storage classes
  */
 enum ir_variable_mode {
-   ir_var_auto = 0,     /**< Function local variables and globals. */
-   ir_var_uniform,      /**< Variable declared as a uniform. */
-   ir_var_shader_storage,   /**< Variable declared as an ssbo. */
+   ir_var_auto = 0,             /**< Function local variables and globals. */
+   ir_var_uniform,              /**< Variable declared as a uniform. */
+   ir_var_shader_storage,       /**< Variable declared as an ssbo. */
    ir_var_shader_in,
    ir_var_shader_out,
    ir_var_function_in,
    ir_var_function_out,
    ir_var_function_inout,
-   ir_var_const_in,	/**< "in" param that must be a constant expression */
-   ir_var_system_value, /**< Ex: front-face, instance-id, etc. */
-   ir_var_temporary,	/**< Temporary variable generated during compilation. */
-   ir_var_mode_count	/**< Number of variable modes */
+   ir_var_const_in,             /**< "in" param that must be a constant expression */
+   ir_var_system_value,         /**< Ex: front-face, instance-id, etc. */
+   ir_var_temporary,            /**< Temporary variable generated during compilation. */
+   ir_var_mode_count            /**< Number of variable modes */
 };

 /**


Added missing function comment under gholder.c.

--- src/gholder.c
+++ src/gholder.c
@@ -485,6 +485,7 @@
   }
 }

+/* A wrapper to set a host item */
 static void
 set_host (GRawDataItem item, GHolder * h, const GPanel * panel, char *data,
           int hits)


QGeoPlacePrivate fix typo

QGeoPlacePrivate fix typo

--- src/location/qgeoplace_p.h
+++ src/location/qgeoplace_p.h
@@ -87,7 +87,7 @@
 // This results in multiple symbol definition errors on all other compilers
 // but not having a definition here results in an attempt to use the unspecialized
 // clone (which fails because of the pure virtuals above)
-template<> QTM_PREPEND_NAMESPACE(QGePlacePrivate) *QSharedDataPointer<QTM_PREPEND_NAMESPACE(QGeoPlacePrivate)>::clone()
+template<> QTM_PREPEND_NAMESPACE(QGeoPlacePrivate) *QSharedDataPointer<QTM_PREPEND_NAMESPACE(QGeoPlacePrivate)>::clone()
 {
     return d->clone();
 }


Fix whoopsi typos

Fix whoopsi typos

--- src/opcontrol.c
+++ src/opcontrol.c
@@ -20,8 +20,8 @@
 typedef enum
 FlywheelPreset
 {
-    FLYWHEEL_SHORTRANGE;
-    FLYWHEEL_LONGRANGE;
+    FLYWHEEL_SHORTRANGE,
+    FLYWHEEL_LONGRANGE
 }
 FlywheelPreset;


Add Bluetooth disconnection graphics

Add Bluetooth disconnection graphics

--- src/c/main.c
+++ src/c/main.c
@@ -20,7 +20,8 @@
   APPLY_MACRO(X,tr(watch_icon, ICON_WATCH_6X11)) \
   APPLY_MACRO(X,tr(watch_charging_icon, ICON_WATCH_CHARGING_6X11)) \
   APPLY_MACRO(X,tr(phone_icon, ICON_PHONE_6X11)) \
-  APPLY_MACRO(X,tr(phone_charging_icon, ICON_PHONE_CHARGING_6X11))
+  APPLY_MACRO(X,tr(phone_charging_icon, ICON_PHONE_CHARGING_6X11)) \
+  APPLY_MACRO(X,tr(phone_disconnected_icon, ICON_PHONE_DISCONNECTED_6X11))

 #define GFONTS_WITH_RESOURCE_IDS_METAMACRO(X, tr) \
   APPLY_MACRO(X,tr(time_font, FONT_ARVO_BOLD_48)) \
@@ -76,6 +77,7 @@
 static int s_watch_batt_charging = 0;
 static int s_phone_batt_level = 0;
 static int s_phone_batt_charging = 0;
+static int s_phone_connected = 0;

 static const char* weekdays[] = {
   "SU", "MO", "TU", "WE", "TH", "FR", "SA"};
@@ -153,6 +155,11 @@

 static void outbox_sent_callback(DictionaryIterator *iterator, void *context) {
   //APP_LOG(APP_LOG_LEVEL_INFO, "Outbox send success!");
+}
+
+static void bluetooth_callback(bool connected) {
+  s_phone_connected = connected;
+  layer_mark_dirty(s_phone_batt_layer);
 }

 static void init_watch_text_layer(TextLayer *text_layer) {
@@ -187,11 +194,14 @@
   graphics_fill_rect(ctx, bounds, 0, GCornerNone);
   graphics_context_set_text_color(ctx, GColorWhite);
   graphics_draw_bitmap_in_rect(ctx,
-    s_phone_batt_charging ? s_phone_charging_icon : s_phone_icon,
+    s_phone_connected
+      ? s_phone_batt_charging ? s_phone_charging_icon : s_phone_icon
+      : s_phone_disconnected_icon,
     GRect(0,0,6,11));
   graphics_context_set_fill_color(ctx, GColorDarkGray);
   graphics_fill_rect(ctx, GRect(8,1,bounds.size.w-8,9), 0, GCornerNone);
-  graphics_context_set_fill_color(ctx, GColorGreen);
+  graphics_context_set_fill_color(ctx,
+    s_phone_connected ? GColorGreen : GColorVividViolet);
   graphics_fill_rect(ctx, GRect(8,1,bar_width,9), 0, GCornerNone);
 }

@@ -291,9 +301,6 @@
   // Show the Window on the watch, with animated=true
   window_stack_push(s_main_window, true);

-  // Register for watch battery level updates
-  battery_state_service_subscribe(watch_battery_state_callback);
-
   // Register callbacks
   app_message_register_inbox_received(inbox_received_callback);
   app_message_register_inbox_dropped(inbox_dropped_callback);
@@ -308,6 +315,17 @@
   // Register with TickTimerService
   tick_timer_service_subscribe(MINUTE_UNIT, tick_handler);

+  // Register for Bluetooth connection updates
+  connection_service_subscribe((ConnectionHandlers) {
+    .pebble_app_connection_handler = bluetooth_callback
+  });
+
+  // Show the correct state of the BT connection from the start
+  bluetooth_callback(connection_service_peek_pebble_app_connection());
+
+  // Register for watch battery level updates
+  battery_state_service_subscribe(watch_battery_state_callback);
+
   // Ensure watch battery level is displayed from the start
   watch_battery_state_callback(battery_state_service_peek());


[LINUX] Fix glx build

[LINUX] Fix glx build

--- src/glx/glx.c
+++ src/glx/glx.c
@@ -1356,7 +1356,7 @@
     // TODO: what if active context is not on the drawable?
     realize_textures();
     if (glstate->list.active){
-        flush();
+        gl4es_flush();
     }
     if (glstate->raster.bm_drawing)
         bitmap_flush();


[GLES2] Fix glBitmap blitter

[GLES2] Fix glBitmap blitter

--- src/gl/blit.c
+++ src/gl/blit.c
@@ -177,7 +177,7 @@
 "varying lowp vec4 vColor;                              \n\t" \
 "void main(){                                           \n\t" \
 "lowp vec4 p = texture2D(uTex, vTexCoord);              \n\t" \
-"if (p.a>0.0) discard;                                  \n\t" \
+"if (p.a==0.0) discard;                                 \n\t" \
 "gl_FragColor = p*vColor;                               \n\t" \
 "}                                                      \n\t";


Added comments

Added comments

--- src/c/main.c
+++ src/c/main.c
@@ -56,10 +56,10 @@

 	if (settings_get_appGlanceEnabled()) { // Check if app glance is enabled
 		char app_glance_text[79];
-		if (settings_get_appGlanceType() == 0) {
+		if (settings_get_appGlanceType() == 0) { // Show last session time on app glance
 			snprintf(app_glance_text, sizeof(app_glance_text), localize_get_app_glance_text(settings_get_appGlanceType(), data_read_last_duration_data()), data_read_last_duration_data());
 		}
-		else {
+		else { // Show total daily time on app glance
 			snprintf(app_glance_text, sizeof(app_glance_text), localize_get_app_glance_text(settings_get_appGlanceType(), data_read_breathe_persist_data()), data_read_breathe_persist_data());
 		}
 		app_glance_reload(appglance_update_app_glance, app_glance_text); // Reload app glance


Fix for v0.9.1

Fix for v0.9.1

--- src/gl/hint.c
+++ src/gl/hint.c
@@ -74,3 +74,4 @@
             gles_glHint(pname, mode);
     }
 }
+void glHint(GLenum pname, GLenum mode) AliasExport("gl4es_glHint");


groonga: add support for --pid-path in standalone mode

--- src/groonga.c
+++ src/groonga.c
@@ -443,6 +443,45 @@
   }
 }

+static void
+create_pid_file(void)
+{
+  FILE *pid_file = NULL;
+
+  if (!pid_file_path) {
+    return;
+  }
+
+  pid_file = fopen(pid_file_path, "w");
+  if (!pid_file) {
+    fprintf(stderr,
+            "Failed to open PID file: <%s>: <%s>\n",
+            pid_file_path, grn_strerror(errno));
+    return;
+  }
+
+  {
+#ifdef WIN32
+    DWORD pid;
+    pid = GetCurrentProcessId();
+    fprintf(pid_file, "%" GRN_FMT_DWORD "\n", pid);
+#else /* WIN32 */
+    pid_t pid;
+    pid = grn_getpid();
+    fprintf(pid_file, "%d\n", pid);
+#endif /* WIN32 */
+  }
+  fclose(pid_file);
+}
+
+static void
+clean_pid_file(void)
+{
+  if (pid_file_path) {
+    grn_unlink(pid_file_path);
+  }
+}
+
 static int
 do_alone(int argc, char **argv)
 {
@@ -450,6 +489,7 @@
   char *path = NULL;
   grn_obj *db;
   grn_ctx ctx_, *ctx = &ctx_;
+  create_pid_file();
   grn_ctx_init(ctx, 0);
   if (argc > 0 && argv) { path = *argv++; argc--; }
   db = (newdb || !path) ? grn_db_create(ctx, path, NULL) : grn_db_open(ctx, path);
@@ -482,6 +522,7 @@
     fprintf(stderr, "db open failed (%s): %s\n", path, ctx->errbuf);
   }
   grn_ctx_fin(ctx);
+  clean_pid_file();
   return exit_code;
 }

@@ -898,45 +939,6 @@
   }
   close_ready_notify_pipe();
   return GRN_TRUE;
-}
-
-static void
-create_pid_file(void)
-{
-  FILE *pid_file = NULL;
-
-  if (!pid_file_path) {
-    return;
-  }
-
-  pid_file = fopen(pid_file_path, "w");
-  if (!pid_file) {
-    fprintf(stderr,
-            "Failed to open PID file: <%s>: <%s>\n",
-            pid_file_path, grn_strerror(errno));
-    return;
-  }
-
-  {
-#ifdef WIN32
-    DWORD pid;
-    pid = GetCurrentProcessId();
-    fprintf(pid_file, "%" GRN_FMT_DWORD "\n", pid);
-#else /* WIN32 */
-    pid_t pid;
-    pid = grn_getpid();
-    fprintf(pid_file, "%d\n", pid);
-#endif /* WIN32 */
-  }
-  fclose(pid_file);
-}
-
-static void
-clean_pid_file(void)
-{
-  if (pid_file_path) {
-    grn_unlink(pid_file_path);
-  }
 }

 static int
@@ -3888,7 +3890,6 @@
           "  -t, --max-threads <max threads>:\n"
           "                                specify max number of threads (default: %u)\n"
           "      --pid-path <path>:        specify file to write process ID to\n"
-          "                                (daemon mode only)\n"
           "      --default-request-timeout <timeout>:\n"
           "                                specify the default request timeout in seconds\n"
           "                                (default: %f)\n"


groonga: fix wrong rc type

groonga: fix wrong rc type

rc doesn't mean grn_rc... It just return value of a program.

--- src/groonga.c
+++ src/groonga.c
@@ -863,11 +863,11 @@
   }
 }

-static grn_rc
+static int
 run_server(grn_ctx *ctx, grn_obj *db, grn_com_event *ev,
            grn_edge_dispatcher_func dispatcher, grn_handler_func handler)
 {
-  grn_rc rc = 0;
+  int rc = EXIT_SUCCESS;
   struct hostent *he;
   if (!(he = gethostbyname(hostname))) {
     SERR("gethostbyname");
@@ -876,7 +876,7 @@
     grn_edges_init(ctx, dispatcher);
     if (!grn_com_sopen(ctx, ev, bind_address, port, handler, he)) {
       run_server_loop(ctx, ev);
-      rc = 0;
+      rc = EXIT_SUCCESS;
     } else {
       fprintf(stderr, "grn_com_sopen failed (%s:%d): %s\n",
               bind_address, port, ctx->errbuf);


Use one line for one variable

Use one line for one variable

--- src/groonga.c
+++ src/groonga.c
@@ -2634,15 +2634,22 @@
 int
 main(int argc, char **argv)
 {
-  const char *port_arg = NULL, *encoding_arg = NULL,
-    *max_num_threads_arg = NULL, *log_level_arg = NULL,
-    *bind_address_arg = NULL, *hostname_arg = NULL, *protocol_arg = NULL,
-    *log_path_arg = NULL, *query_log_path_arg = NULL,
-    *cache_limit_arg = NULL, *document_root_arg = NULL,
-    *default_command_version_arg = NULL,
-    *default_match_escalation_threshold_arg = NULL,
-    *input_fd_arg = NULL, *output_fd_arg = NULL,
-    *working_directory_arg = NULL;
+  const char *port_arg = NULL;
+  const char *encoding_arg = NULL;
+  const char *max_num_threads_arg = NULL;
+  const char *log_level_arg = NULL;
+  const char *bind_address_arg = NULL;
+  const char *hostname_arg = NULL;
+  const char *protocol_arg = NULL;
+  const char *log_path_arg = NULL;
+  const char *query_log_path_arg = NULL;
+  const char *cache_limit_arg = NULL;
+  const char *document_root_arg = NULL;
+  const char *default_command_version_arg = NULL;
+  const char *default_match_escalation_threshold_arg = NULL;
+  const char *input_fd_arg = NULL;
+  const char *output_fd_arg = NULL;
+  const char *working_directory_arg = NULL;
   const char *config_path = NULL;
   int exit_code = EXIT_SUCCESS;
   int i;


Added VACATE_SERVICE for accountant

Added VACATE_SERVICE for accountant

--- src/h/sched.h
+++ src/h/sched.h
@@ -164,6 +164,7 @@
 #define	MATCH_INFO			(SCHED_VERS+40)
 #define	ALIVE				(SCHED_VERS+41)
 #define	REQUEST_SERVICE		(SCHED_VERS+42)
+#define	VACATE_SERVICE		(SCHED_VERS+43)

 #define SCHED_PORT		9605
 #define START_PORT		9611


Deprecate PAPI_RES_STL until we can figure out a definition that properly counts resource stalls.

--- src/p4_events.c
+++ src/p4_events.c
@@ -85,7 +85,7 @@

 const hwi_search_t _papi_hwd_pentium4_mlt2_preset_map[] = {
 /* preset, derived, native index array */
-   {PAPI_RES_STL, {0, {PNE_replay_event, PAPI_NULL,}, {0,}}},
+//   {PAPI_RES_STL, {0, {PNE_replay_event, PAPI_NULL,}, {0,}}},
    {PAPI_BR_INS, {0, {PNE_branch_retired_all, PAPI_NULL,}, {0,}}},
    {PAPI_BR_TKN, {0, {PNE_branch_retired_taken, PAPI_NULL,}, {0,}}},
    {PAPI_BR_NTK, {0, {PNE_branch_retired_not_taken, PAPI_NULL,}, {0,}}},
@@ -112,7 +112,7 @@

 const hwi_search_t _papi_hwd_pentium4_mge2_preset_map[] = {
 /* preset, derived, native index array */
-   {PAPI_RES_STL, {0, {PNE_replay_event, PAPI_NULL,}, {0,}}},
+//   {PAPI_RES_STL, {0, {PNE_replay_event, PAPI_NULL,}, {0,}}},
    {PAPI_BR_INS, {0, {PNE_branch_retired_all, PAPI_NULL,}, {0,}}},
    {PAPI_BR_TKN, {0, {PNE_branch_retired_taken, PAPI_NULL,}, {0,}}},
    {PAPI_BR_NTK, {0, {PNE_branch_retired_not_taken, PAPI_NULL,}, {0,}}},


Incremeant size if bucket empty.

Incremeant size if bucket empty.

--- src/luxa/collections/map.c
+++ src/luxa/collections/map.c
@@ -70,9 +70,12 @@
 	}

 	map->keys[index] = hash;
-	map->entry_states[index] = 1;
 	memcpy(((char *)map->items) + map->element_size * index, item, map->element_size);
-	map->size++;
+
+	if (!map->entry_states[index]) {
+		map->size++;
+		map->entry_states[index] = 1;
+	}
 }

 static void rehash(lx_map_t *map)


CCBC-689: Remove stray abort when receiving MCD_EINVAL

Change-Id: I73217926252197bfaae717aca50d23a0bac7a215
Reviewed-on: http://review.couchbase.org/62204
Reviewed-by: Subhashni Balakrishnan <7129c8e37b832c7bd362ff375532d24b98ef5162@gmail.com>
Tested-by: Mark Nunberg <dab05a0fe859c5cb93882b2a75a0d613501b07be@couchbase.com>

--- src/handler.c
+++ src/handler.c
@@ -92,8 +92,6 @@
     case PROTOCOL_BINARY_RESPONSE_SUBDOC_MULTI_PATH_FAILURE:
         return LCB_SUBDOC_MULTI_FAILURE;
     case PROTOCOL_BINARY_RESPONSE_EINVAL:
-        printf("Got memcached EINVAL!\n");
-        abort();
         return LCB_EINVAL_MCD;
     case PROTOCOL_BINARY_RESPONSE_NOT_STORED:
         return LCB_NOT_STORED;


display updated & auto mode fixed

display updated & auto mode fixed

--- src/client.c
+++ src/client.c
@@ -14,7 +14,7 @@
 #include "othello.h"
 #include "othello-client.h"

-#define OTHELLO_DEFAULT_SERVER_ADRESS "78.226.157.77"
+#define OTHELLO_DEFAULT_SERVER_ADRESS "172.16.131.89"

 othello_client_enum_t client_state;
 char othello_board[OTHELLO_BOARD_LENGTH][OTHELLO_BOARD_LENGTH];
@@ -105,16 +105,16 @@

 	printf("\n   ");
 	for (i = 0; i < OTHELLO_BOARD_LENGTH; ++i){
-		printf("%d",i+1);
+		printf("%d ",i+1);
 	}
 	printf("\n   ");
-	for (i = 0; i < OTHELLO_BOARD_LENGTH; ++i){
+	for (i = 0; i < OTHELLO_BOARD_LENGTH * 2 - 1; ++i){
 		printf("-");
 	}
 	for (i = 0; i < OTHELLO_BOARD_LENGTH; ++i){
 		printf("\n%c| ",(char)(i+65));
 		for(j = 0; j < OTHELLO_BOARD_LENGTH; ++j){
-			printf("%c",othello_board[i][j]);
+			printf("%c ",othello_board[i][j]);
 		}
 	}
 	printf("\n\n");
@@ -504,7 +504,7 @@
 void othello_read_mesg(int sock, char* buff,size_t bytes_to_read){
   ssize_t n;
 	if((n = read(sock, buff, bytes_to_read)) != bytes_to_read){
-		printf("Error : Can't read the server answer : n -> %zu / bytes -> %zu\n",n,bytes_to_read);
+		printf("Error : Can't read the server answer!\n",n,bytes_to_read);

 	}
 }
@@ -850,7 +850,7 @@
 				break;
 				case OTHELLO_CLIENT_INPUT_AUTO:
 					auto_mode = !auto_mode;
-					if(client_state = OTHELLO_CLIENT_STATE_PLAYING)
+					if(client_state == OTHELLO_CLIENT_STATE_PLAYING)
 						othello_send_auto_move(socket_descriptor);
 				break;
 				case OTHELLO_CLIENT_INPUT_EXIT:


added addModelHandler to VRMainInterface

--- src/main/VRMainInterface.h
+++ src/main/VRMainInterface.h
@@ -24,6 +24,7 @@
 public:
   virtual void addEventHandler(VREventHandler *eHandler) = 0;
   virtual void addRenderHandler(VRRenderHandler *rHandler) = 0;
+  virtual void addModelHandler(VRModelHandler* modelHandler) = 0;
   virtual void addInputDevice(VRInputDevice *dev) = 0;
   virtual VRDataIndex* getConfig() = 0;
   virtual VRGraphicsToolkit* getGraphicsToolkit(const std::string &name) = 0;


debbuging message reading

debbuging message reading

--- src/client.c
+++ src/client.c
@@ -27,7 +27,7 @@
 	pthread_t thread_write;

 	while((ptr_host = othello_ask_server_adress()) == NULL){
-		printf("Impossible to find a server at this adress, please try again :");
+		printf("Impossible to find a server at this adress, please try again :\n");
 	}

     // copy char by char of informations from ptr_host to adresse_locale
@@ -38,13 +38,13 @@

  	//socket creation
     if ((socket_descriptor = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
-		perror("erreur : impossible de creer la socket de connexion avec le serveur.");
+		perror("erreur : impossible de creer la socket de connexion avec le serveur.\n");
 		exit(1);
     }

 	//server connection try with informations onto adresse_locale
     if ((connect(socket_descriptor, (sockaddr*)(&adresse_locale), sizeof(adresse_locale))) < 0) {
-		perror("erreur : impossible de se connecter au serveur.");
+		perror("erreur : impossible de se connecter au serveur.\n");
 		exit(1);
     }

@@ -58,12 +58,12 @@
 	(void) pthread_join(thread_write, NULL);
 	close(socket_descriptor);

-	printf("Thanks for playing, see you soon!");
+	printf("Thanks for playing, see you soon!\n");
 	return 0;
 }

 hostent* othello_ask_server_adress(){
-	char* user_input = "172.16.134.151";
+	char* user_input = "localhost";

 	//printf("Welcome, please enter the server adresse : ");
 	//if(othello_read_user_input(user_input,sizeof user_input)==0){
@@ -370,7 +370,7 @@
 void othello_choose_nickname(int socket_descriptor){
 	char user_input[33];

-	printf("Choose a nickname : ");
+	printf("Choose a nickname : \n");
 	if(othello_read_user_input(user_input,sizeof user_input)==0){
 		othello_create_user_request(user_input,sizeof user_input,OTHELLO_QUERY_CONNECT);
 		othello_write_mesg(socket_descriptor,user_input,sizeof user_input);
@@ -380,22 +380,25 @@
 }

 void othello_choose_room(int socket_descriptor){
-	char user_input[6];
-
-	printf("Type a room ID or 'list' to display the list of them : ");
+	char user_input[5];
+	char room_list;
+	char room_join[2];
+	printf("Type a room ID or 'list' to display the list of them : \n");
 	if(othello_read_user_input(user_input,sizeof user_input)==0){
 		if(othello_is_number(user_input)){
-			othello_create_user_request(user_input,sizeof user_input,OTHELLO_QUERY_ROOM_JOIN);
-			othello_write_mesg(socket_descriptor,user_input,sizeof user_input);
+			room_join[0] = atoi(user_input);
+			room_join[1] = ' ';
+			othello_create_user_request(room_join, sizeof room_join, OTHELLO_QUERY_ROOM_JOIN);
+			othello_write_mesg(socket_descriptor, room_join, sizeof room_join);
 			client_state = OTHELLO_CLIENT_STATE_WAITING;
-			printf("Waiting for server answer ");
+			printf("Waiting for server answer \n");
 		}else if(strcmp(user_input,"list")==0){
-			othello_create_user_request(user_input,1,OTHELLO_QUERY_ROOM_LIST);
-			othello_write_mesg(socket_descriptor,user_input,sizeof user_input);
+			othello_create_user_request(&room_list, sizeof room_list, OTHELLO_QUERY_ROOM_LIST);
+			othello_write_mesg(socket_descriptor, &room_list, sizeof room_list);
 			client_state = OTHELLO_CLIENT_STATE_WAITING;
-			printf("Waiting for server answer ");
+			printf("Waiting for server answer \n");
 		}else{
-			printf("Invalid input !\n");
+			printf("Choose Room : Invalid input !\n");
 		}
 	}
 }
@@ -417,7 +420,7 @@

 void othello_display_moves(){
 	int i,j = 0;
-	printf("Possible moves : ");
+	printf("Possible moves : \n");
 	for (i = 0; i < OTHELLO_BOARD_LENGTH; ++i){
 		for(j = 0; j < OTHELLO_BOARD_LENGTH; ++j){
 			if(othello_move_valid(i,j,my_color)){
@@ -431,10 +434,10 @@
 void othello_send_move(int socket_descriptor){
 	char user_input[4];
 	int read_result = othello_read_user_input(user_input,sizeof user_input);
-	printf("Type your move : ");
+	printf("Type your move : \n");
 	if(read_result==0){
 		if( ((int)user_input[0] < 65) || ((int)user_input[0] > 72) ||  ((int)user_input[1] < 49) || ((int)user_input[1] > 56) ){ /* A1 to H8 */
-			printf("The coordinate are out of board, please try again : ");
+			printf("The coordinate are out of board, please try again : \n");
 		}else{
 			user_input[0] = (char)((int)user_input[0] - 17); // A -> 0, B -> 1, etc ...
 			user_input[1] = (char)((int)user_input[1] - 1); // 1 -> 0, 2 -> 1, 3-> 2, etc...
@@ -450,65 +453,70 @@
 	char message[strlen(msg)-3];
 	memcpy(&message[1],&msg[4],strlen(msg)-4);
 	message[strlen(message)] = '\0';
-	othello_create_user_request(message,sizeof message,OTHELLO_QUERY_MESSAGE);
-	othello_write_mesg(socket_descriptor,message,sizeof message);
+	othello_create_user_request(message, sizeof message, OTHELLO_QUERY_MESSAGE);
+	othello_write_mesg(socket_descriptor, message, sizeof message);
 }

 void othello_server_connect(int socket_descriptor){
 	char server_answer;
-	othello_read_mesg(socket_descriptor,&server_answer,sizeof(server_answer));
+	othello_read_mesg(socket_descriptor, &server_answer, sizeof(server_answer));
 	if(server_answer == OTHELLO_SUCCESS){
 		client_state = OTHELLO_CLIENT_STATE_CONNECTED;
 		printf("You are now connected to the server\n");
 	}else{
 		printf("Invalid nickname ...\n");
+		client_state = OTHELLO_CLIENT_STATE_NICKNAME;
 	}
 }
 void othello_server_room_list(int socket_descriptor){
-	char server_answer[200];
+	char server_answer[(2 + OTHELLO_ROOM_LENGTH * OTHELLO_PLAYER_NAME_LENGTH) * OTHELLO_NUMBER_OF_ROOMS];
 	othello_read_mesg(socket_descriptor,server_answer,sizeof(server_answer));
-	printf("List of rooms :");
+	printf("List of rooms :\n");
+	client_state = OTHELLO_CLIENT_STATE_CONNECTED;
 }
 void othello_server_room_join(int socket_descriptor){
-	char server_answer[3];
-	othello_read_mesg(socket_descriptor,server_answer,sizeof(server_answer));
-	if(server_answer[1] == 1){
+	char server_answer;
+	othello_read_mesg(socket_descriptor,&server_answer,sizeof(server_answer));
+	if(server_answer == OTHELLO_SUCCESS){
 		client_state = OTHELLO_CLIENT_STATE_INROOM;
 		printf("You are now into a room\n");
 	}else{
 		printf("Impossible to join the room ...\n");
+		client_state = OTHELLO_CLIENT_STATE_CONNECTED;
 	}
 }
 void othello_server_message(int socket_descriptor){
 	printf("L'autre joueur vous envoie un message : ...\n");
 }
 void othello_server_ready(int socket_descriptor){
-	char server_answer[3];
-	othello_read_mesg(socket_descriptor,server_answer,sizeof(server_answer));
-	if(server_answer[1] == 1){
+	char server_answer;
+	othello_read_mesg(socket_descriptor,&server_answer,sizeof(server_answer));
+	if(server_answer == OTHELLO_SUCCESS){
 		client_state = OTHELLO_CLIENT_STATE_READY;
 		printf("You are now ready to play\n");
 	}else{
+		OTHELLO_CLIENT_STATE_INROOM;
 		printf("Server can't ready you ...\n");
 	}
 }
 void othello_server_play(int socket_descriptor){
-	char server_answer[3];
-	othello_read_mesg(socket_descriptor,server_answer,sizeof(server_answer));
-	if(server_answer[1] == 1){
+	char server_answer;
+	othello_read_mesg(socket_descriptor,&server_answer,sizeof(server_answer));
+	if(server_answer == OTHELLO_SUCCESS){
 		client_state = OTHELLO_CLIENT_STATE_WAITING;
 		printf("Votre coup a été validé\n");
 		othello_notif_play(socket_descriptor,my_color);
 	}else{
+		client_state = OTHELLO_CLIENT_STATE_PLAYING;
 		printf("Votre coup est invalide ...\n");
 	}
 }

 void othello_notif_play(int socket_descriptor, char color){
-	char server_answer[4];
+	char server_answer[2];
 	othello_read_mesg(socket_descriptor,server_answer,sizeof(server_answer));
-	othello_board[server_answer[1]][server_answer[2]] = color;
-	othello_return_tokens((int)(server_answer[1]-48),(int)(server_answer[2]-48),color);
+	othello_board[server_answer[0]][server_answer[1]] = color;
+	othello_return_tokens((int)(server_answer[0]-48),(int)(server_answer[1]-48),color);
 }

 void* othello_write_thread(void* sock){


removed the hard-coded proxy locations II

--- src/handler.c
+++ src/handler.c
@@ -114,10 +114,7 @@
         return;
     }

-    if (memcmp(translated->path, "http://", 7) == 0)
-        proxy_callback(request, translated);
-    else
-        file_callback(request, translated);
+    file_callback(request, translated);
 }

 static void


Only define __STDC_LIMIT_MACROS if not already defined.

--- src/headers.h
+++ src/headers.h
@@ -18,7 +18,13 @@
 #endif
 #define _WIN32_IE 0x0400
 #define WIN32_LEAN_AND_MEAN 1
+
+// Include boost/foreach here as it defines __STDC_LIMIT_MACROS on some systems.
+#include <boost/foreach.hpp>
+#ifndef __STDC_LIMIT_MACROS
 #define __STDC_LIMIT_MACROS // to enable UINT64_MAX from stdint.h
+#endif
+
 #if (defined(__unix__) || defined(unix)) && !defined(USG)
 #include <sys/param.h>  // to get BSD define
 #endif
@@ -48,8 +54,6 @@
 #include <list>
 #include <deque>
 #include <map>
-
-#include <boost/foreach.hpp>

 #ifdef WIN32
 #include <windows.h>


Fix #define guard in Attribute.h

Fix #define guard in Attribute.h

--- src/main/actor/Attribute.h
+++ src/main/actor/Attribute.h
@@ -1,5 +1,5 @@
-#ifndef ACTOR_H_
-#define ACTOR_H_
+#ifndef ATTRIBUTE_H_
+#define ATTRIBUTE_H_

 /**
  * The Attribute class manages Actor attributes such as Strength and Dexterity,


Allow focus of minimized windows (issue #62).

--- src/client.c
+++ src/client.c
@@ -799,9 +799,6 @@
    if(np->state.status & STAT_HIDDEN) {
       return;
    }
-   if(!(np->state.status & (STAT_MAPPED | STAT_SHADED))) {
-      return;
-   }

    if(activeClient != np || !(np->state.status & STAT_ACTIVE)) {


Hack to work around inifinite loop

Hack to work around inifinite loop

When the hotlist is full, this code will loop forever trying to add the
socket to the hotlist.  A 100ms sleep will let things make progress; the
better long-term solution is to forcibly evict a FD from the hotlist to
make room since handler sockets should always have priority, but that's
a more complicated change

--- src/handler.c
+++ src/handler.c
@@ -222,6 +222,7 @@
             break;
         } else if( rc == -1 || parser->target_count <= 0) {
             log_warn("Skipped invalid message from handler: %s", bdata(handler->send_spec));
+            taskdelay(100);
             continue;
         } else {
             for(i = 0; i < (int)parser->target_count; i++) {


avoid malloc/cpy/free

avoid malloc/cpy/free

--- src/hirlite.c
+++ src/hirlite.c
@@ -2707,10 +2707,8 @@
 	if (retval == RL_NOT_FOUND) {
 		c->reply = createReplyObject(RLITE_REPLY_NIL);
 	} else {
-		c->reply = createStringObject((char *)value, valuelen);
-	}
-
-	rl_free(value);
+		c->reply = createTakeStringObject((char *)value, valuelen);
+	}
 cleanup:
 	return;
 }


headers.h: fix windows build

headers.h: fix windows build

Hopefully :)

--- src/headers.h
+++ src/headers.h
@@ -14,7 +14,7 @@
 #ifdef _WIN32_WINNT
 #undef _WIN32_WINNT
 #endif
-#define _WIN32_WINNT 0x0500
+#define _WIN32_WINNT 0x0501
 #ifdef _WIN32_IE
 #undef _WIN32_IE
 #endif


fix uninitialized history entry

fix uninitialized history entry

--- src/history.c
+++ src/history.c
@@ -89,6 +89,8 @@
                            char *src, char *text) {
     struct sircc_history_entry entry;

+    memset(&entry, 0, sizeof(struct sircc_history_entry));
+
     entry.type = SIRCC_HISTORY_CHAN_MSG;
     entry.date = time(NULL);
     entry.src = src;


直接归并排序法

直接归并排序法

error: pathspec 'ExternalSort/merge_sort.c' did not match any file(s) known to git

--- ExternalSort/merge_sort.c
+++ ExternalSort/merge_sort.c
@@ -0,0 +1,164 @@
+/* 直接归并排序法 */
+
+#include <stdio.h>
+#include <stdlib.h>
+#define LEN 8   //最大元素个数
+
+/* 直接归并排序 */
+void merge_sort(FILE *merge,FILE *sort1,FILE *sort2,int len)
+{
+	int s1,s2;		//数据计数
+	int i,j,k;
+	char c,c1,c2;
+
+	for(i = 1; i < len; i *= 2)
+	{
+		//分割文件
+		for(j = 0; j < len / 2; j++)   //分割文件一
+		{
+			c = getc(merge);
+			putc(c,sort1);
+		}
+
+		for(; j < len; j++)  //分到文件二
+		{
+			c = getc(merge);
+			putc(c,sort2);
+		}
+
+		rewind(merge);	//重设文件指针
+		rewind(sort1);
+		rewind(sort2);
+
+		for(k = 0; k < len / 2; k += i) //归并循环
+		{
+			c1 = getc(sort1);	//读取第一分割文件
+			c2 = getc(sort2);	//读取第二分割文件
+			s1 = s2 = 0;		//设置计数初值
+
+			while(1)
+			{
+				if(c1 < c2)  //比较两个值
+				{
+					//第一分割文件小，存入主文件
+					putc(c1,merge);
+					s1++;  //计数加1
+					if(s1 < i)  //是否未读完
+						c1 = getc(sort1);	//读取第一分割文件
+					else
+						break;	//跳出循环
+				}
+
+				else
+				{
+					//第二分割文件小，存入主文件
+					putc(c2,merge);
+					s2++;  //计数加2
+					if(s2 < i)   //是否未读完
+					{
+						c2 = getc(sort2);   //读取第一分割文件
+					}
+					else
+					{
+						break;  //跳出循环
+					}
+
+				}
+			}
+
+			//第一分割文件是否是最后一条
+			if(s1 < i)  //处理最后一条
+			{
+				putc(c1,merge);  //存入主文件
+				s1++;  //计数加1
+			}
+
+			//第二分割文件是否是最后一笔
+			if(s2 < i)  //处理最后一笔
+			{
+				putc(c2,merge);	//存入主文件
+				s2++;		//计数加1
+			}
+
+			//第一分割文件
+			while(s1 < i)   //取出剩下的数据
+			{
+				c = getc(sort1);	//读取第一分割文件
+				putc(c,merge);		//存入主文件
+				s1++;		//计数加1
+			}
+
+			//第二分割文件
+			while(s2 < i)  //取出剩下的数据
+			{
+				c =  getc(sort2);   //读取第二分割文件
+				putc(c,merge);		//存入主文件
+				s2++;		//计数加1
+			}
+		}
+
+		rewind(merge);   //重设文件指针
+		rewind(sort1);
+		rewind(sort2);
+	}
+
+}
+
+int main()
+{
+	FILE *data;	//数据文件
+	FILE *fp;	//主文件指针
+	FILE *fp1;	//第一分割文件指针
+	FILE *fp2;	//第二分割文件指针
+	char c;
+	int j;
+
+	data = fopen("data.txt","r");   //打开数据文件
+
+	if(data == NULL)
+	{
+		printf("数据文件打开错误！\n");
+		exit(0);
+	}
+
+	fp = fopen("result.txt","r+"); //打开主文件
+	if(fp == NULL)
+	{
+		printf("主文件打开错误！\n");
+	}
+	else
+	{
+		for(j = 0; j < LEN; j++)  //拷贝数据到主文件
+		{
+			c = getc(data);  //读取数据
+			putc(c,fp);		 //存入数据
+		}
+		fclose(data);		//关闭数据文件
+		rewind(fp);			//重设文件指针
+		fp1 = fopen("split1.txt","r+");	//打开第二分割文件
+		if(fp1 == NULL)
+		{
+			printf("第一分割文件打开错误！\n");
+		}
+		else
+		{
+			fp2 = fopen("split2.txt","r+");  //打开第二分割文件
+			if(fp2 == NULL)
+			{
+				printf("第二分割文件打开错误！\n");
+			}
+			else
+			{
+				printf("数据处理中，请稍待。。。\n");
+				merge_sort(fp,fp1,fp2,LEN);  //直接归并排序法
+				printf("数据处理完成！\n");
+				fclose(fp);
+				fclose(fp1);
+				fclose(fp2);
+			}
+		}
+
+	}
+	return 0;
+}
+


fiddled a bit with the ID3v2 debugging messsages

git-svn-id: 793bb72743a407948e3701719c462b6a765bc435@364 35dc7657-300d-0410-a2e5-dc2837fedb53

--- src/common.c
+++ src/common.c
@@ -153,7 +153,7 @@
 	/* length-10 or length-20 (footer present); 4 synchsafe integers == 28 bit number  */
 	/* we have already read 10 bytes, so left are length or length+10 bytes belonging to tag */
 	if(!syncsafe_to_long(buf+2,length)) return -1;
-
+	debug1("ID3v2: tag data length %lu", length);
 	/* skip if unknown version/scary flags, parse otherwise */
 	if((flags & UNKNOWN_FLAGS) || (major > 4))
 	{
@@ -196,7 +196,7 @@
 						for(; i< 4; ++i) if( !( ((tagdata[tagpos+i] > 47) && (tagdata[tagpos+i] < 58))
 						                     || ((tagdata[tagpos+i] > 64) && (tagdata[tagpos+i] < 91)) ) )
 						{
-							debug("ID3v2: I guess the tag ended...");
+							debug1("ID3v2: real tag data apparently ended after %lu bytes", tagpos);
 							ret = -1;
 							break;
 						}
@@ -212,6 +212,7 @@
 								error("ID3v2: non-syncsafe frame size, aborting");
 								break;
 							}
+							debug2("ID3v2: %s frame of size %lu", id, framesize);
 							tagpos += 10 + framesize; /* the important advancement in whole tag */
 							pos += 4;
 							fflags = (((unsigned long) tagdata[pos]) << 8) | ((unsigned long) tagdata[pos+1]);
@@ -229,7 +230,11 @@
 							#define UNSYNC_FFLAG 2
 							#define DATLEN_FFLAG 1
 							/* shall not or want not handle these */
-							if(fflags & (BAD_FFLAGS | COMPR_FFLAG | ENCR_FFLAG)) continue;
+							if(fflags & (BAD_FFLAGS | COMPR_FFLAG | ENCR_FFLAG))
+							{
+								warning("ID3v2: skipping invalid/unsupported frame");
+								continue;
+							}

 							for(i = 0; i < 4; ++i)
 							if(!strncmp(rva_type[i], id, 4)){ tt = i+1; break; }
@@ -267,7 +272,6 @@
 									debug2("ID3v2: de-unsync made %lu out of %lu bytes", realsize, framesize);
 								}
 								pos = 0; /* now at the beginning again... */
-								debug1("ID3v2: found something that could give me RVA info: a %s frame", rva_type[tt-1]);
 								switch(tt)
 								{
 									case 1: /* a comment that perhaps is a RVA / RVA_ALBUM/AUDIOPHILE / RVA_MIX/RADIO one */
@@ -290,7 +294,7 @@
 											{
 												char* comstr;
 												size_t comsize = realsize-4-(strlen((char*)realdata+pos)+1);
-												debug1("ID3v2: going to intepret/store content of %s comment as RVA info", realdata+pos);
+												debug1("ID3v2: evaluating %s data for RVA", realdata+pos);
 												if((comstr = (char*) malloc(comsize+1)) != NULL)
 												{
 													memcpy(comstr,realdata+realsize-comsize, comsize);
@@ -333,7 +337,7 @@
 											{
 												char* comstr;
 												size_t comsize = realsize-1-(strlen((char*)realdata+pos)+1);
-												debug1("ID3v2: going to intepret/store content of %s extra field as RVA info", realdata+pos);
+												debug1("ID3v2: evaluating %s data for RVA", realdata+pos);
 												if((comstr = (char*) malloc(comsize+1)) != NULL)
 												{
 													memcpy(comstr,realdata+realsize-comsize, comsize);


Give non-http enabled builds the debunk_mime function; that spares us cluttering playlist.c with #ifdefs.

git-svn-id: 793bb72743a407948e3701719c462b6a765bc435@1021 35dc7657-300d-0410-a2e5-dc2837fedb53

--- src/httpget.c
+++ src/httpget.c
@@ -48,26 +48,6 @@
 	/* the other stuff shall persist */
 }

-#if !defined(WIN32) && !defined(GENERIC)
-
-#include <string.h>
-
-#define HTTP_MAX_RELOCATIONS 20
-
-#include <netdb.h>
-#include <sys/param.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <errno.h>
-#include <ctype.h>
-
-#include "true.h"
-
-#ifndef INADDR_NONE
-#define INADDR_NONE 0xffffffff
-#endif
-
 /* mime type classes */
 #define M_FILE 0
 #define M_M3U  1
@@ -105,6 +85,27 @@
 	}
 	return r;
 }
+
+
+#if !defined(WIN32) && !defined(GENERIC)
+
+#include <string.h>
+
+#define HTTP_MAX_RELOCATIONS 20
+
+#include <netdb.h>
+#include <sys/param.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <errno.h>
+#include <ctype.h>
+
+#include "true.h"
+
+#ifndef INADDR_NONE
+#define INADDR_NONE 0xffffffff
+#endif

 int writestring (int fd, char *string)
 {


Made copy constructor and assignment operator protected. A derived class might need this (at least the copy constructor).

--- FMD/AliFMDReconstructor.h
+++ FMD/AliFMDReconstructor.h
@@ -88,13 +88,6 @@
   virtual void   SetESD(AliESD* esd) { fESD = esd; }

 private:
-  /** Copy CTOR
-      @param other Object to copy from. */
-  AliFMDReconstructor(const AliFMDReconstructor& other);
-  /** Assignment operator
-      @param other Object to assign from
-      @return reference to this object */
-  AliFMDReconstructor& operator=(const AliFMDReconstructor& other);
   /** Hide base classes unused function */
   void Reconstruct(AliRawReader*, TTree*) const;
   /** Hide base classes unused function */
@@ -109,6 +102,13 @@
   void FillESD(AliRunLoader*, AliRawReader*, AliESD*) const;

 protected:
+  /** Copy CTOR
+      @param other Object to copy from. */
+  AliFMDReconstructor(const AliFMDReconstructor& other);
+  /** Assignment operator
+      @param other Object to assign from
+      @return reference to this object */
+  AliFMDReconstructor& operator=(const AliFMDReconstructor& other);
   /** Process AliFMDDigit objects in @a digits.  For each digit, find
       the psuedo-rapidity @f$ \eta@f$, azimuthal angle @f$ \varphi@f$,
       energy deposited @f$ E@f$, and psuedo-inclusive multiplicity @f$


removing unused functions

removing unused functions

--- src/ignotum.c
+++ src/ignotum.c
@@ -13,18 +13,6 @@
 		free(*pp);
 		*pp = NULL;
 	}
-}
-
-const char *ignotum_strerror(ignotum_status code){
-	static const char *str_err[]={
-		"success",
-		"invalid pid number",
-		"failed to open map",
-		"failed to open mem",
-		"pid number overflow",
-	};
-
-	return (code < IGNOTUM_ERR_SIZE) ? str_err[code] : "invalid error code";
 }

 void strrev(char *dest, const char *src, size_t size){


Final (?) change to banner, use standard unicode bullet U+25CF

This patch to the banner "hello" is hopefully the last in this new style
progress.  Previous efforts have used unicode symbols not available in
all fonts.  This time we standardize on one that looks good both the
default Ubuntu Mono and Source Code Pro fonts.  It's a bit small in my
preferred font, Envy Code R, but that might be a mistake in the font.

Not tested with PuTTY or Windows Hyper Terminal.  I think they use the
Courier font by default, both of them, which I have tested.

Signed-off-by: Joachim Nilsson <583c295fd7602c168ad814279bbc3894ba65f5d6@gmail.com>

--- src/helpers.c
+++ src/helpers.c
@@ -146,8 +146,13 @@
 	} else {
 		size_t wmax = 80 <= SCREEN_WIDTH ? 80 : SCREEN_WIDTH;

+		/* • • • Foo System ═══════════════════════════════════════════════ */
+		/* ⬤ ⬤ ⬤ Foo System ═══════════════════════════════════════════════ */
+		/* ⚉ ⚉ ⚉ Foo System ═══════════════════════════════════════════════ */
+		/* o o o Foo System ═══════════════════════════════════════════════ */
+		/* ◉ ◉ ◉ Foo System ═══════════════════════════════════════════════ */
 		/* ⦿⦿⦿ Foo System ═══════════════════════════════════════════════ */
-		strlcat(buf, "\e[1;31m⦿ \e[1;33m⦿ \e[1;32m⦿ \e[0m\e[1m ", sizeof(buf));
+		strlcat(buf, "\e[1;31m● \e[1;33m● \e[1;32m● \e[0m\e[1m ", sizeof(buf));
 		strlcat(buf, heading, sizeof(buf));

 		/*


Working on @Crossover.

Working on @Crossover.

--- src/common.c
+++ src/common.c
@@ -971,7 +971,29 @@
 Father: pointer to the father tree
 Mother: pointer to the mother tree
 p: probability of mutation on a function node */
-Node **Crossover(Node *Father, Node *Mother, float p);
+Node **Crossover(Node *Father, Node *Mother, float p){
+    Node **offspring = NULL, *aux_father = NULL, *aux_mother = NULL;
+    int ctr = 0, crossover_point, size_tree;
+    double r;
+    char left_son;
+
+    if(!Father || !Mother){
+        fprintf(stderr,"\nInvalid input data @Crossover.\n");
+        return NULL;
+    }
+
+    offspring = (Node **)malloc(2*sizeof(Node *));
+
+    /* It generates the offsprings */
+    size_tree = getSizeTree(Father);
+    crossover_point = round(GenerateUniformRandomNumber(2, size_tree)); /* Crossover point cannot be the root (min=2) */
+    offspring[0] = CopyTree(Father);
+    r = GenerateUniformRandomNumber(0,1);
+    if(p >= r) aux_father = PreFixPositioningTree(offspring[0], crossover_point, &left_son, FUNCTION, &ctr); /* the mutation point is a function node */
+    else aux_father = PreFixPositioningTree(offspring[0], crossover_point, &left_son, TERMINAL, &ctr); /* the mutation point is a terminal node */
+
+    return offspring;
+}

 /* It returns the parent of the pos-th node using a prefix travel
 Paremeters:


Handle OOM

Handle OOM

--- src/hirlite.c
+++ src/hirlite.c
@@ -3605,7 +3605,8 @@
 					free(c->reply); c->reply = NULL);
 			for (i = 0; i < objc; i++) {
 				// TODO free elements on oom
-				CHECK_OOM(c->reply->element[i] = createTakeStringObject((char *)objv[i], objvlen[i]));
+				CHECK_OOM_ELSE(c->reply->element[i] = createTakeStringObject((char *)objv[i], objvlen[i]),
+						c->reply->elements = i - 1; rliteFreeReplyObject(c->reply); c->reply = NULL);
 			}
 		} else {
 			c->reply = createReplyObject(RLITE_REPLY_ARRAY);


little header cleanup in common.c

little header cleanup in common.c

git-svn-id: 793bb72743a407948e3701719c462b6a765bc435@883 35dc7657-300d-0410-a2e5-dc2837fedb53

--- src/common.c
+++ src/common.c
@@ -11,7 +11,6 @@
 /* #include <ctype.h> */
 #include <sys/stat.h>
 #include <sys/time.h>
-#include <math.h>

 #include <fcntl.h>


Fix a mistake in the error checking

Fix a mistake in the error checking

This is a small bug that was introduced long time ago, with commit
84563c6303a4ab263ea19c973d3f0bbfe6fc0955.

--- src/hw_frog.c
+++ src/hw_frog.c
@@ -182,7 +182,7 @@
 		// Read the ready byte.
 		unsigned char answer[1] = {0};
 		status = dc_iostream_read (device->iostream, answer, sizeof (answer), NULL);
-		if (status != sizeof (answer)) {
+		if (status != DC_STATUS_SUCCESS) {
 			ERROR (abstract->context, "Failed to receive the ready byte.");
 			return status;
 		}


Popraw gg_vsaprintf() dla nie-C99

Popraw gg_vsaprintf() dla nie-C99

git-svn-id: 5ce22904ebd2e91e07686586c06e775ed4fb9e1a@1212 d0e0d552-48cc-411f-a74d-6ebdfb0732cf

--- src/common.c
+++ src/common.c
@@ -38,6 +38,17 @@

 #include "libgadu.h"

+#ifndef GG_CONFIG_HAVE_VA_COPY
+#  ifdef GG_CONFIG_HAVE___VA_COPY
+#    define va_copy(dest, src) __va_copy((dest), (src))
+#  else
+/* Taka wersja va_copy() działa poprawnie tylko na platformach, które
+ * va_copy() de facto wcale nie potrzebują, np. MSVC. Definicja tylko dla
+ * przejrzystości kodu. */
+#    define va_copy(dest, src) (dest) = (src)
+#  endif
+#endif
+
 /**
  * \internal Odpowiednik funkcji \c vsprintf alokujący miejsce na wynik.
  *
@@ -53,59 +64,49 @@
  */
 char *gg_vsaprintf(const char *format, va_list ap)
 {
-	int size = 0;
+	int size;
 	char *buf = NULL;
-
-#ifdef GG_CONFIG_HAVE_VA_COPY
 	va_list aq;
-
-	va_copy(aq, ap);
-#else
-#  ifdef GG_CONFIG_HAVE___VA_COPY
-	va_list aq;
-
-	__va_copy(aq, ap);
-#  endif
-#endif

 #ifndef GG_CONFIG_HAVE_C99_VSNPRINTF
 	{
-		int res;
+		int res = 0;
 		char *tmp;

 		size = 128;
 		do {
-			size *= 2;
+			if (res > size) {
+				/* Jednak zachowanie zgodne z C99. */
+				size = res + 1;
+			} else {
+				size *= 2;
+			}
+
 			if (!(tmp = realloc(buf, size))) {
 				free(buf);
 				return NULL;
 			}
+
 			buf = tmp;
-			res = vsnprintf(buf, size, format, ap);
-		} while (res == size - 1 || res == -1);
+			va_copy(aq, ap);
+			res = vsnprintf(buf, size, format, aq);
+			va_end(aq);
+		} while (res >= size || res < 0);
 	}
 #else
 	{
 		char tmp[2];

+		va_copy(aq, ap);
 		/* libce Solarisa przy buforze NULL zawsze zwracają -1, więc
 		 * musimy podać coś istniejącego jako cel printf()owania. */
-		size = vsnprintf(tmp, sizeof(tmp), format, ap);
-		if (!(buf = malloc(size + 1)))
+		size = vsnprintf(tmp, sizeof(tmp), format, aq) + 1;
+		va_end(aq);
+		if (!(buf = malloc(size)))
 			return NULL;
-	}
-#endif
-
-#ifdef GG_CONFIG_HAVE_VA_COPY
-	vsnprintf(buf, size + 1, format, aq);
-	va_end(aq);
-#else
-#  ifdef GG_CONFIG_HAVE___VA_COPY
-	vsnprintf(buf, size + 1, format, aq);
-	va_end(aq);
-#  else
-	vsnprintf(buf, size + 1, format, ap);
-#  endif
+
+		vsnprintf(buf, size, format, ap);
+	}
 #endif

 	return buf;


update hexchar function

update hexchar function

--- src/ignotum.c
+++ src/ignotum.c
@@ -365,14 +365,18 @@
 }

 char hexchar(const char x){
+	char ret = 0;
+
 	if( x >= '0' && x <= '9' )
-		return x-'0';
-
-	if( x >= 'a' && x <= 'f' )
-		return x-'a'+10;
-
-	if( x >= 'A' && x <= 'F' )
-		return x-'A'+10;
+		ret = x-'0';
+
+	else if( x >= 'a' && x <= 'f' )
+		ret = x-'a'+10;
+
+	else if( x >= 'A' && x <= 'F' )
+		ret = x-'A'+10;
+
+	return ret;
 }

 size_t ignotum_getmappedaddr(int maps_fd, ignotum_mapped_addr_t **out){


- poprawka wyłączonego debugowania (Brzezi/w)

git-svn-id: 5ce22904ebd2e91e07686586c06e775ed4fb9e1a@189 d0e0d552-48cc-411f-a74d-6ebdfb0732cf

--- src/common.c
+++ src/common.c
@@ -39,9 +39,9 @@
 #include "config.h"
 #include "libgadu.h"

+FILE *gg_debug_file = NULL;
+
 #ifndef GG_DEBUG_DISABLE
-
-FILE *gg_debug_file = NULL;

 /*
  * gg_debug() // funkcja wewntrzna


do not extract namespaces from literals

do not extract namespaces from literals

--- src/common.c
+++ src/common.c
@@ -225,12 +225,6 @@

     assert(module && expr && ((!prefixes && !namespaces && !ns_count) || (prefixes && namespaces && ns_count)));

-    if (ns_count) {
-        *ns_count = 0;
-        *prefixes = NULL;
-        *namespaces = NULL;
-    }
-
     exp = lyxp_parse_expr(expr);
     LY_CHECK_RETURN(!exp, 1);

@@ -334,7 +328,7 @@
             literal = lydict_insert(module->ctx, cur_expr + 1, exp->tok_len[i] - 2);

             /* parse literals as subexpressions if possible, otherwise treat as a literal */
-            if (_transform_json2xml_subexp(module, literal, out, out_used, out_size, schema, inst_id, prefixes, namespaces, ns_count)) {
+            if (_transform_json2xml_subexp(module, literal, out, out_used, out_size, schema, inst_id, NULL, NULL, NULL)) {
                 strncpy(&(*out)[*out_used], literal, exp->tok_len[i] - 2);
                 *out_used += exp->tok_len[i] - 2;
             }
@@ -371,6 +365,12 @@
     int ret;

     assert(module && expr && ((!prefixes && !namespaces && !ns_count) || (prefixes && namespaces && ns_count)));
+
+    if (ns_count) {
+        *ns_count = 0;
+        *prefixes = NULL;
+        *namespaces = NULL;
+    }

     if (!expr[0]) {
         /* empty value */


Move private_data field to the end of the SRC_STATE.

--- src/common.h
+++ src/common.h
@@ -126,14 +126,14 @@
 	/* SRC_MODE_PROCESS or SRC_MODE_CALLBACK */
 	enum SRC_MODE	mode ;

-	/* Pointer to data to converter specific data. */
-	void	*private_data ;
-
 	/* Data specific to SRC_MODE_CALLBACK. */
 	src_callback_t	callback_func ;
 	void			*user_callback_data ;
 	long			saved_frames ;
 	const float		*saved_data ;
+
+	/* Pointer to data to converter specific data. */
+	void	*private_data ;
 } ;

 /* In src_sinc.c */


src/common.h : Optimize fmod_one.

src/common.h : Optimize fmod_one.

--- src/common.h
+++ src/common.h
@@ -135,14 +135,13 @@

 static inline double
 fmod_one (double x)
-{	double y = 1.0 ;
-	double i, f ;
+{	double res ;

-	i = floor (x / y) ;
-	f = x - i * y ;
-	if ((x < 0.0) != (y < 0.0))
-		f = f - y ;
-	return f ;
+	res = x - lrint (x) ;
+	if (res < 0.0)
+		return res + 1.0 ;
+
+	return res ;
 } /* fmod_one */

 #endif	/* COMMON_H_INCLUDED */


Get BADMALLOC to behave like a statement.

--- src/include.h
+++ src/include.h
@@ -36,7 +36,7 @@
 #define flt_equals(a, b) (fabs((a) - (b)) < EPSILON)

 #define GETMEM(P, T, N) (P = (T*)malloc(sizeof(T) * N))
-#define BADMALLOC printf("\n  ------> Exit(%d) called by %s(%s.%d)\n\n", 9, __func__, __FILE__, __LINE__); exit(9);
+#define BADMALLOC {printf("\n  ------> Exit(%d) called by %s(%s.%d)\n\n", 9, __func__, __FILE__, __LINE__); exit(9); }
 #define DL printf("-----> AT %s(%s.%d)\n",  __func__, __FILE__, __LINE__);
 #define DLT printf("%lf seconds ", (double)(clock() - start_) / CLOCKS_PER_SEC);
 #define uint unsigned int


common: Remove now unused timespec macros

--- src/common.h
+++ src/common.h
@@ -63,31 +63,6 @@
 #ifndef timespecclear
 #define timespecclear(tsp)      (tsp)->tv_sec = (time_t)((tsp)->tv_nsec = 0L)
 #define timespecisset(tsp)      ((tsp)->tv_sec || (tsp)->tv_nsec)
-#endif
-
-#define timespec_to_double(tv)						     \
-	((double)(tv)->tv_sec + (double)((tv)->tv_nsec) / 1000000000.0)
-#define timespecnorm(tv) do {						     \
-	while ((tv)->tv_nsec >=  NSEC_PER_SEC) {			     \
-		(tv)->tv_sec++;						     \
-		(tv)->tv_nsec -= NSEC_PER_SEC;				     \
-	}								     \
-} while (0 /* CONSTCOND */);
-#define ts_to_ms(ms, tv) do {						     \
-	ms = (tv)->tv_sec * MSEC_PER_SEC;				     \
-	ms += (tv)->tv_nsec / NSEC_PER_MSEC;				     \
-} while (0 /* CONSTCOND */);
-#define ms_to_ts(tv, ms) do {						     \
-	(tv)->tv_sec = ms / MSEC_PER_SEC;				     \
-	(tv)->tv_nsec = (suseconds_t)(ms - ((tv)->tv_sec * MSEC_PER_SEC))    \
-	    * NSEC_PER_MSEC;						     \
-} while (0 /* CONSTCOND */);
-
-#ifndef TIMEVAL_TO_TIMESPEC
-#define	TIMEVAL_TO_TIMESPEC(tv, ts) do {				\
-	(ts)->tv_sec = (tv)->tv_sec;					\
-	(ts)->tv_nsec = (tv)->tv_usec * USEC_PER_NSEC;			\
-} while (0 /* CONSTCOND */)
 #endif

 #if __GNUC__ > 2 || defined(__INTEL_COMPILER)


Fix #314: call cond_update() also when removing all service/foo/*

When removing a whole tree of conditions we need to walk through each
and call cond_update() to ensure that all dependant tasks are stopped
and put back in waiting.

Signed-off-by: Joachim Wiberg <583c295fd7602c168ad814279bbc3894ba65f5d6@gmail.com>

--- src/cond-w.c
+++ src/cond-w.c
@@ -196,19 +196,30 @@

 static int do_delete(const char *fpath, const struct stat *sb, int tflag, struct FTW *ftw)
 {
+	const char *cond, *ptr;
+
 	if (ftw->level == 0)
 		return 1;
+
+	ptr = strstr(fpath, COND_BASE);
+	if (!ptr) {
+		warnx("%s does not seem to be a Finit condition, skipping", fpath);
+		return 0;
+	}

 	if (remove(fpath))
 		err(1, "Failed removing condition %s", fpath);

+	cond = ptr + strlen(COND_BASE) + 1;
+	cond_update(cond);
+
 	return 0;
 }

 static void cond_delpath(const char *path)
 {
 	nftw(path, do_delete, 20, FTW_DEPTH);
-	if (remove(path))
+	if (remove(path) && errno != ENOENT)
 		err(1, "Failed removing condition path %s", path);
 }


cond_set_path(): minor, improve debug, 'new' -> 'next'

 - Avoid using reserved C++ keyword 'new'
 - Rename new -> next
 - Rename old -> prev
 - Add debug for value being set to cond path

Signed-off-by: Joachim Wiberg <583c295fd7602c168ad814279bbc3894ba65f5d6@gmail.com>

--- src/cond-w.c
+++ src/cond-w.c
@@ -127,12 +127,12 @@
 	return 0;
 }

-int cond_set_path(const char *path, enum cond_state new)
-{
-	enum cond_state old;
+int cond_set_path(const char *path, enum cond_state next)
+{
+	enum cond_state prev;
 	unsigned int rgen;

-	_d("%s", path);
+	_d("%s <= %d", path, next);

 	rgen = cond_get_gen(_PATH_RECONF);
 	if (!rgen) {
@@ -140,9 +140,9 @@
 		return -1;
 	}

-	old = cond_get_path(path);
-
-	switch (new) {
+	prev = cond_get_path(path);
+
+	switch (next) {
 	case COND_ON:
 		if (cond_checkpath(path))
 		    return 0;
@@ -159,7 +159,7 @@
 		return 0;
 	}

-	return new != old;
+	return next != prev;
 }

 /* Should only be used by cond_set*(), cond_clear(), and usr plugin! */


Infobar: segfault when client->title is NULL, fixes #132

Signed-off-by: Philippe Pepiot <e888d2bd6f13f82caa51a37c03d034c76f661ba3@philpep.org>

--- src/infobar.c
+++ src/infobar.c
@@ -188,7 +188,7 @@
      else if(sel && !infobar[sc].selbar->mapped)
           barwin_map(infobar[sc].selbar);

-     if(conf.selbar.maxlength >= 0 && sel)
+     if(conf.selbar.maxlength >= 0 && sel && sel->title)
      {
           str = xcalloc(conf.selbar.maxlength + 4, sizeof(char));
           strncpy(str, sel->title, conf.selbar.maxlength);


Beginning to use the error reporting framework

--- src/config.c
+++ src/config.c
@@ -13,6 +13,8 @@
  * You should have received a copy of the Creative Commons Attribution-
  * NonCommercial-ShareAlike 3.0 along with libSystem; if not, browse to
  * http://creativecommons.org/licenses/by-nc-sa/3.0/ */
+/* TODO:
+ * - use the error reporting framework */

@@ -115,7 +117,8 @@
 			|| (fp = fopen(filename, "r")) == NULL)
 	{
 		free(section);
-		return 1;
+		return error_set_code(1, "%s%s%s", filename, ": ",
+				strerror(errno));
 	}
 	while((c = fgetc(fp)) != EOF)
 	{


Don't forget all peers when no peers are configured in peer dirs

--- src/config.c
+++ src/config.c
@@ -1006,9 +1006,8 @@
 			continue;

 		peer->next = *peers;
-	}
-
-	*peers = new_peers;
+		*peers = new_peers;
+	}
 }


Add comment to sdsConfigSet() (#10605)

Add comment to sdsConfigSet() (#10605)

Improve comments to explain the code

Co-authored-by: moticless <49122d62ac7b4520814c69896022900925910355@github.com>
Co-authored-by: Oran Agra <4bc4982385244a2789f53ac695e2aa0ced00df6d@redislabs.com>

--- src/config.c
+++ src/config.c
@@ -1821,10 +1821,16 @@
     UNUSED(argc);
     if (config->data.sds.is_valid_fn && !config->data.sds.is_valid_fn(argv[0], err))
         return 0;
+
     sds prev = config->flags & MODULE_CONFIG ? getModuleStringConfig(config->privdata) : *config->data.sds.config;
     sds new = (config->data.string.convert_empty_to_null && (sdslen(argv[0]) == 0)) ? NULL : argv[0];
+
+    /* if prev and new configuration are not equal, set the new one */
     if (new != prev && (new == NULL || prev == NULL || sdscmp(prev, new))) {
+        /* If MODULE_CONFIG flag is set, then free temporary prev getModuleStringConfig returned.
+         * Otherwise, free the actual previous config value Redis held (Same action, different reasons) */
         sdsfree(prev);
+
         if (config->flags & MODULE_CONFIG) {
             return setModuleStringConfig(config->privdata, new, err);
         }


Actually bail

Actually bail

Signed-off-by: Ikey Doherty <15e2f59c60e9d84348e78a87e24660774f739add@intel.com>

--- src/inifile.c
+++ src/inifile.c
@@ -171,6 +171,7 @@
                         if (buf[str_len-1] != ']') {
                                 /* Throw error */
                                 fprintf(stderr, "[inifile] Expected closing ']' on line %d\n", line_count);
+                                goto next;
                         }
                         /* Grab the section name, and "close" last section */
                         buf[str_len-1] = '\0';


Avoid memory leaks when overwriting existing values

--- src/config.c
+++ src/config.c
@@ -150,7 +150,11 @@
 		string_delete(newvalue);
 		return 1;
 	}
-	string_delete(oldvalue);
+	if(oldvalue != NULL)
+	{
+		string_delete(p);
+		string_delete(oldvalue);
+	}
 	return 0;
 }


initctl: minor refactor and set min column width

Signed-off-by: Joachim Wiberg <583c295fd7602c168ad814279bbc3894ba65f5d6@gmail.com>

--- src/initctl.c
+++ src/initctl.c
@@ -52,15 +52,17 @@
 int numeric  = 0;
 int verbose  = 0;
 int runlevel = 0;
+int iw, pw;

 /* figure ut width of IDENT and PID columns */
-static void col_widths(int *identw, int *pidw)
+static void col_widths(void)
 {
 	char ident[MAX_IDENT_LEN];
 	char pid[10];
 	svc_t *svc;
-	int iw = 0;
-	int pw = 0;
+
+	iw = 0;
+	pw = 0;

 	for (svc = client_svc_iterator(1); svc; svc = client_svc_iterator(0)) {
 		int w, p;
@@ -79,8 +81,11 @@
 			pw = p;
 	}

-	*identw = iw;
-	*pidw = pw;
+	/* adjust for min col width */
+	if (iw < 5)
+		iw = 5;
+	if (pw < 3)
+		pw = 3;
 }

 static int runlevel_get(int *prevlevel)
@@ -268,9 +273,8 @@
 	char ident[MAX_IDENT_LEN];
 	enum cond_state cond;
 	svc_t *svc;
-	int iw, pw;
-
-	col_widths(&iw, &pw);
+
+	col_widths();
 	if (heading) {
 		char title[80];

@@ -437,7 +441,6 @@
 {
 	char ident[MAX_IDENT_LEN];
 	svc_t *svc;
-	int iw, pw;

 	/* Fetch UTMP runlevel, needed for svc_status() call below */
 	runlevel = runlevel_get(NULL);
@@ -463,7 +466,7 @@
 		return do_log(svc->cmd);
 	}

-	col_widths(&iw, &pw);
+	col_widths();
 	if (heading) {
 		char title[80];


Fixed output order error when no sort header configed.

--- src/config.c
+++ src/config.c
@@ -182,8 +182,10 @@
 		}
 	}

-	if (sort_header != NULL && config->header_num > 0) {
-		if (parse_sort_headers(config, sort_header) == -1) {
+	if (config->header_num > 0) {
+		const char *sh = sort_header == NULL ? "" : sort_header;
+
+		if (parse_sort_headers(config, sh) == -1) {
 			save_errno = errno;
 			goto end;
 		}


Update output message to match others.

Update output message to match others.

--- src/config.c
+++ src/config.c
@@ -177,7 +177,7 @@
 	}

 	if (skip_runas != 1 && runas_user == NULL) {
-		fatal("missing runas user");
+		fatal("missing runas user, use -r to skip it");
 	}

 	if (getuid() != 0 && skip_runas == 0) {


Fix config_set_numerical_field() integer overflow.

--- src/config.c
+++ src/config.c
@@ -1062,15 +1062,15 @@
     /* Numerical fields.
      * config_set_numerical_field(name,var,min,max) */
     } config_set_numerical_field(
-      "tcp-keepalive",server.tcpkeepalive,0,LLONG_MAX) {
-    } config_set_numerical_field(
-      "maxmemory-samples",server.maxmemory_samples,1,LLONG_MAX) {
-    } config_set_numerical_field(
-      "lfu-log-factor",server.lfu_log_factor,0,LLONG_MAX) {
-    } config_set_numerical_field(
-      "lfu-decay-time",server.lfu_decay_time,0,LLONG_MAX) {
-    } config_set_numerical_field(
-      "timeout",server.maxidletime,0,LONG_MAX) {
+      "tcp-keepalive",server.tcpkeepalive,0,INT_MAX) {
+    } config_set_numerical_field(
+      "maxmemory-samples",server.maxmemory_samples,1,INT_MAX) {
+    } config_set_numerical_field(
+      "lfu-log-factor",server.lfu_log_factor,0,INT_MAX) {
+    } config_set_numerical_field(
+      "lfu-decay-time",server.lfu_decay_time,0,INT_MAX) {
+    } config_set_numerical_field(
+      "timeout",server.maxidletime,0,INT_MAX) {
     } config_set_numerical_field(
       "active-defrag-threshold-lower",server.active_defrag_threshold_lower,0,1000) {
     } config_set_numerical_field(
@@ -1082,15 +1082,15 @@
     } config_set_numerical_field(
       "active-defrag-cycle-max",server.active_defrag_cycle_max,1,99) {
     } config_set_numerical_field(
-      "active-defrag-max-scan-fields",server.active_defrag_max_scan_fields,1,LLONG_MAX) {
-    } config_set_numerical_field(
-      "auto-aof-rewrite-percentage",server.aof_rewrite_perc,0,LLONG_MAX){
-    } config_set_numerical_field(
-      "hash-max-ziplist-entries",server.hash_max_ziplist_entries,0,LLONG_MAX) {
-    } config_set_numerical_field(
-      "hash-max-ziplist-value",server.hash_max_ziplist_value,0,LLONG_MAX) {
-    } config_set_numerical_field(
-      "stream-node-max-bytes",server.stream_node_max_bytes,0,LLONG_MAX) {
+      "active-defrag-max-scan-fields",server.active_defrag_max_scan_fields,1,LONG_MAX) {
+    } config_set_numerical_field(
+      "auto-aof-rewrite-percentage",server.aof_rewrite_perc,0,INT_MAX){
+    } config_set_numerical_field(
+      "hash-max-ziplist-entries",server.hash_max_ziplist_entries,0,LONG_MAX) {
+    } config_set_numerical_field(
+      "hash-max-ziplist-value",server.hash_max_ziplist_value,0,LONG_MAX) {
+    } config_set_numerical_field(
+      "stream-node-max-bytes",server.stream_node_max_bytes,0,LONG_MAX) {
     } config_set_numerical_field(
       "stream-node-max-entries",server.stream_node_max_entries,0,LLONG_MAX) {
     } config_set_numerical_field(
@@ -1098,40 +1098,40 @@
     } config_set_numerical_field(
       "list-compress-depth",server.list_compress_depth,0,INT_MAX) {
     } config_set_numerical_field(
-      "set-max-intset-entries",server.set_max_intset_entries,0,LLONG_MAX) {
-    } config_set_numerical_field(
-      "zset-max-ziplist-entries",server.zset_max_ziplist_entries,0,LLONG_MAX) {
-    } config_set_numerical_field(
-      "zset-max-ziplist-value",server.zset_max_ziplist_value,0,LLONG_MAX) {
-    } config_set_numerical_field(
-      "hll-sparse-max-bytes",server.hll_sparse_max_bytes,0,LLONG_MAX) {
-    } config_set_numerical_field(
-      "lua-time-limit",server.lua_time_limit,0,LLONG_MAX) {
+      "set-max-intset-entries",server.set_max_intset_entries,0,LONG_MAX) {
+    } config_set_numerical_field(
+      "zset-max-ziplist-entries",server.zset_max_ziplist_entries,0,LONG_MAX) {
+    } config_set_numerical_field(
+      "zset-max-ziplist-value",server.zset_max_ziplist_value,0,LONG_MAX) {
+    } config_set_numerical_field(
+      "hll-sparse-max-bytes",server.hll_sparse_max_bytes,0,LONG_MAX) {
+    } config_set_numerical_field(
+      "lua-time-limit",server.lua_time_limit,0,LONG_MAX) {
     } config_set_numerical_field(
       "slowlog-log-slower-than",server.slowlog_log_slower_than,0,LLONG_MAX) {
     } config_set_numerical_field(
-      "slowlog-max-len",ll,0,LLONG_MAX) {
+      "slowlog-max-len",ll,0,LONG_MAX) {
       /* Cast to unsigned. */
         server.slowlog_max_len = (unsigned long)ll;
     } config_set_numerical_field(
       "latency-monitor-threshold",server.latency_monitor_threshold,0,LLONG_MAX){
     } config_set_numerical_field(
-      "repl-ping-slave-period",server.repl_ping_slave_period,1,LLONG_MAX) {
-    } config_set_numerical_field(
-      "repl-timeout",server.repl_timeout,1,LLONG_MAX) {
-    } config_set_numerical_field(
-      "repl-backlog-ttl",server.repl_backlog_time_limit,0,LLONG_MAX) {
-    } config_set_numerical_field(
-      "repl-diskless-sync-delay",server.repl_diskless_sync_delay,0,LLONG_MAX) {
-    } config_set_numerical_field(
-      "slave-priority",server.slave_priority,0,LLONG_MAX) {
+      "repl-ping-slave-period",server.repl_ping_slave_period,1,INT_MAX) {
+    } config_set_numerical_field(
+      "repl-timeout",server.repl_timeout,1,INT_MAX) {
+    } config_set_numerical_field(
+      "repl-backlog-ttl",server.repl_backlog_time_limit,0,LONG_MAX) {
+    } config_set_numerical_field(
+      "repl-diskless-sync-delay",server.repl_diskless_sync_delay,0,INT_MAX) {
+    } config_set_numerical_field(
+      "slave-priority",server.slave_priority,0,INT_MAX) {
     } config_set_numerical_field(
       "slave-announce-port",server.slave_announce_port,0,65535) {
     } config_set_numerical_field(
-      "min-slaves-to-write",server.repl_min_slaves_to_write,0,LLONG_MAX) {
+      "min-slaves-to-write",server.repl_min_slaves_to_write,0,INT_MAX) {
         refreshGoodSlavesCount();
     } config_set_numerical_field(
-      "min-slaves-max-lag",server.repl_min_slaves_max_lag,0,LLONG_MAX) {
+      "min-slaves-max-lag",server.repl_min_slaves_max_lag,0,INT_MAX) {
         refreshGoodSlavesCount();
     } config_set_numerical_field(
       "cluster-node-timeout",server.cluster_node_timeout,0,LLONG_MAX) {
@@ -1140,17 +1140,17 @@
     } config_set_numerical_field(
       "cluster-announce-bus-port",server.cluster_announce_bus_port,0,65535) {
     } config_set_numerical_field(
-      "cluster-migration-barrier",server.cluster_migration_barrier,0,LLONG_MAX){
-    } config_set_numerical_field(
-      "cluster-slave-validity-factor",server.cluster_slave_validity_factor,0,LLONG_MAX) {
-    } config_set_numerical_field(
-      "hz",server.hz,0,LLONG_MAX) {
+      "cluster-migration-barrier",server.cluster_migration_barrier,0,INT_MAX){
+    } config_set_numerical_field(
+      "cluster-slave-validity-factor",server.cluster_slave_validity_factor,0,INT_MAX) {
+    } config_set_numerical_field(
+      "hz",server.hz,0,INT_MAX) {
         /* Hz is more an hint from the user, so we accept values out of range
          * but cap them to reasonable values. */
         if (server.hz < CONFIG_MIN_HZ) server.hz = CONFIG_MIN_HZ;
         if (server.hz > CONFIG_MAX_HZ) server.hz = CONFIG_MAX_HZ;
     } config_set_numerical_field(
-      "watchdog-period",ll,0,LLONG_MAX) {
+      "watchdog-period",ll,0,INT_MAX) {
         if (ll)
             enableWatchdog(ll);
         else


Small fix to data-dir migrator logic

Small fix to data-dir migrator logic

--- src/insobot.c
+++ src/insobot.c
@@ -988,30 +988,30 @@
 		       "*   Press Y to move this directory, or N to keep it where it is currently.   *\n"
 		       "*     If not moved, the bot will start with a blank set of module data.      *\n"
 		       "******************************************************************************");
-	}
-
-	int opt = 0;
-	if(isatty(STDOUT_FILENO)){
-		do {
-			if(opt != '\n'){
-				printf("\nMove the data directory? (Y/N) > ");
-				fflush(stdout);
-			}
-			opt = getchar();
-		} while(!strchr("yYnN", opt));
-	} else {
-		printf("stdout isn't a tty, assuming Y.\n");
-		opt = 'y';
-	}
-
-	if(opt == 'y' || opt == 'Y'){
-		if(rename(oldpath, newpath) == -1){
-			perror("rename");
+
+		int opt = 0;
+		if(isatty(STDOUT_FILENO)){
+			do {
+				if(opt != '\n'){
+					printf("\nMove the data directory? (Y/N) > ");
+					fflush(stdout);
+				}
+				opt = getchar();
+			} while(!strchr("yYnN", opt));
 		} else {
-			printf("Successfully moved data directory.\n");
-		}
-	} else {
-		printf("Keeping old data directory in place.\n");
+			printf("stdout isn't a tty, assuming Y.\n");
+			opt = 'y';
+		}
+
+		if(opt == 'y' || opt == 'Y'){
+			if(rename(oldpath, newpath) == -1){
+				perror("rename");
+			} else {
+				printf("Successfully moved data directory.\n");
+			}
+		} else {
+			printf("Keeping old data directory in place.\n");
+		}
 	}
 }


make getChar on a (semi)closed stdin fail

--- src/iomonad.c
+++ src/iomonad.c
@@ -14,8 +14,8 @@
  * the license in the file "License", which is included in the distribution.
  *
  * $RCSfile: iomonad.c,v $
- * $Revision: 1.87 $
- * $Date: 2004/11/11 00:17:16 $
+ * $Revision: 1.88 $
+ * $Date: 2004/11/12 18:12:56 $
  * ------------------------------------------------------------------------*/

 Name nameIORun;			        /* run IO code                     */
@@ -772,7 +772,15 @@
  * ------------------------------------------------------------------------*/

 primFun(primGetChar) {			/* Get character from stdin        */
-    Int c = FGetChar(stdin);
+    Int c;
+    if (!(handles[HSTDIN].hmode&(HREAD|HREADWRITE))) {
+	IOFail(mkIOError(&handles[HSTDIN].hcell,
+			 nameIllegal,
+			 "getChar",
+			 "handle is (semi-)closed",
+			 NULL));
+    }
+    c = FGetChar(stdin);
     if (c==EOF) {
 	IOFail(mkIOError(&handles[HSTDIN].hcell,
 			 nameEOFErr,


Fixes the config use of the hashmap

Fixes the config use of the hashmap

--- src/config.c
+++ src/config.c
@@ -41,8 +41,8 @@
 					current_data++;
 				}
 			}
-			HashMap *pairs = hm_get(doc.items, *current_section, current_section); //Get the key-value pairs of the current section
-			hm_put(pairs, *key, key, data); //put this key-value pair into it
+			HashMap *pairs = hm_get(doc.items, *current_section, &current_section); //Get the key-value pairs of the current section
+			hm_put(pairs, *key, &key, data); //put this key-value pair into it
 		}
 		contents++;
 	}


[core] fix pipe open in unix, tested only for reading

git-svn-id: 6e74a02f85675cec270f5d931b0f6998666294a3@38721 d31e2699-5ff4-0310-a27c-f18f2fbe73fe

--- src/io/unix.c
+++ src/io/unix.c
@@ -641,6 +641,8 @@
 #  ifdef PARROT_HAS_HEADER_UNISTD
     int pid, err, fds[2];

+    Parrot_io_eprintf(interp, "open pipe: '%Ss' - %i\n", command, flags);
+
     err = pipe(fds);
     if (err < 0) {
         return NULL;
@@ -695,6 +697,13 @@
                 exit(EXIT_SUCCESS);
         }

+        /*******************************************************
+         *     THIS IS A QUICK TEST IMPLEMENTATION
+         * Thus the ifdef'ed out code is not deleted yet
+         * TT #661
+         *******************************************************
+         */
+        #if 0
         /* XXX ugly hack to be able to pass some arguments
          *     split cmd at blanks */
         orig_cmd = cmd = Parrot_str_to_cstring(interp, command);
@@ -710,6 +719,16 @@

         Parrot_str_free_cstring(c); /* done with C string */
         execv(cmd, argv);       /* XXX use execvp ? */
+        #else
+
+        orig_cmd = cmd = Parrot_str_to_cstring(interp, command);
+        argv [0] = "/bin/sh";
+        argv [1] = "-c";
+        argv [2] = cmd;
+        argv [3] = NULL;
+        execv(argv [0], argv);
+
+        #endif

         /* Will never reach this unless exec fails. */
         Parrot_str_free_cstring(orig_cmd);


patch config.h for sync_file_range

patch config.h for sync_file_range

--- src/config.h
+++ src/config.h
@@ -56,12 +56,13 @@
  * the plain fsync() call. */
 #ifdef __linux__
 #include <linux/version.h>
+#include <features.h>
 #ifdef __GLIBC__
-#if (LINUX_VERSION_CODE >= 0x020617 && GLIBC_VERSION_AT_LEAST(2, 6))
+#if (LINUX_VERSION_CODE >= 0x020611 && __GLIBC_PREREQ(2, 6))
 #define HAVE_SYNC_FILE_RANGE 1
 #endif
 #else
-#if (LINUX_VERSION_CODE >= 0x020617)
+#if (LINUX_VERSION_CODE >= 0x020611)
 #define HAVE_SYNC_FILE_RANGE 1
 #endif
 #endif


istream: don't allow failures in .available()

--- src/istream.h
+++ src/istream.h
@@ -206,9 +206,9 @@

 #ifndef NDEBUG
     assert(available >= -1);
-
-    if (pool_denotify(&notify) || istream->destroyed)
-        return available;
+    assert(!pool_denotify(&notify));
+    assert(!istream->destroyed);
+    assert(istream->reading);

     istream->reading = false;


Make colour table const

Make colour table const

https://bugzilla.gnome.org/show_bug.cgi?id=546765

--- src/cr-rgb.c
+++ src/cr-rgb.c
@@ -28,7 +28,7 @@
 #include "cr-term.h"
 #include "cr-parser.h"

-static CRRgb gv_standard_colors[] = {
+static const CRRgb gv_standard_colors[] = {
         {"aliceblue", 240, 248, 255, 0,},
         {"antiquewhite", 250, 235, 215, 0},
         {"aqua", 0, 255, 255, 0},


Copy package script to the repository if it has been specified in the manifest

--- src/create.c
+++ src/create.c
@@ -95,6 +95,11 @@
 		snprintf(path, PATH_MAX, "%s/%s/manifest", repodir, pkg->name);
 		manifest_emit(pkg, path);

+		if (pkg->script) {
+			snprintf(path, PATH_MAX, "%s/%s/script", repodir, pkg->name);
+			mpkg_copy(pkg->script, path);
+		}
+
 		manifest_free(pkg);
 	}


Try Again!

Try Again!

--- src/ctrans.c
+++ src/ctrans.c
@@ -809,7 +809,7 @@
 #if PY_MAJOR_VERSION >= 3
 static struct PyModuleDef moduledef = {
     PyModuleDef_HEAD_INIT,
-    "skxray.core.ctrans",
+    "ctrans",
     "Python functions to perform gridding (binning) of experimental data.\n\n",
     -1, // we keep state in global vars
     ctrans_methods,


Moved large int parsing logic into a helper function.

--- large-u-int.c
+++ large-u-int.c
@@ -51,86 +51,87 @@
   }
 }

+// Processes one input character to set the value of this. Returns 1 to
+// continue parsing the 0 when we've reached the end of this large unsigned
+// integer. The starting state is -1.
+static int ParseCharacter(int current, LargeUInt* this, int* state) {
+  printf("Current char: %c this->num_bytes: %i\n", current, this->num_bytes_);
+  if (current == '#') {
+    *state = -6;  // skip comment state
+    return 1;
+  }
+
+  if (*state == -6) {
+    // Comments end with a newline character.
+    if (current == '\n') {
+      *state = -1;
+    }
+    return 1;
+  }
+
+  if (*state == -5) {  // Looking for the _ between num_bytes and byte values.
+    if (current == '_') {
+      *state = 0;  // Start looking for a byte's value.
+    }
+    return 1;
+  }
+
+  int current_value = HexCharToNibble(current);
+  if (current_value == -1) {
+    // Skip over non hex characters.
+    return 1;
+  }
+
+  switch (*state) {
+    case -1:  // Looking for char 1 of 4 in num_bytes.
+      this->num_bytes_ = current_value << 4;
+      *state = -2;
+      return 1;
+    case -2:  // Looking for char 2 of 4 in num_bytes.
+      this->num_bytes_ += current_value;
+      *state = -3;
+      return 1;
+    case -3:  // Looking for char 3 of 4 in num_bytes.
+      this->num_bytes_ += current_value << 12;
+      *state = -4;
+      return 1;
+    case -4:  // Looking for char 4 of 4 in num_bytes.
+      this->num_bytes_ += current_value << 8;
+      *state = -5;  // Reached the end of num_bytes.
+      return 1;
+  }
+
+  if (*state % 2 == 0) {
+    this->bytes_[*state / 2] = current_value << 4;
+    (*state)++;  // Has read the upper nibble of the byte.
+  } else {
+    this->bytes_[(*state - 1) / 2] += current_value;
+    (*state)++;
+    if ((*state / 2) >= this->num_bytes_) {
+      return 0;
+    }
+  }
+  return 1;
+}
+
 void LargeUIntRead(FILE* in, LargeUInt* this) {
   if (in == NULL) {
     ErrorOut("Invalid file, unable to read LargeUInt.\n");
   }

   int current = fgetc(in);
-  int state = 0;  // start state
-  int num_bytes = 0;
-  int byte_index = 0;
-  int current_value = -1;
-  int byte_value = 0;
-  this->num_bytes_ = 0;
+  int state = -1;  // start state
+  this->num_bytes_ = 0;
+
   while (1) {
     if (feof(in)) {
       break;
     }
-
-    if (current == '#') {
-      state = 7;  // skip comment state
+
+    if (ParseCharacter(current, this, &state) == 0) {
+      return;
     }

-    if (state == 7) {
-      // Comments end with a newline character.
-      if (current == '\n') {
-        state = 0;
-      }
-      current = fgetc(in);
-      continue;
-    }
-
-    if (state == 4) {  // Looking for the _ between num_bytes and byte values.
-      if (current == '_') {
-        state = 5;  // Start looking for a byte's value.
-      }
-      current = fgetc(in);
-      continue;
-    }
-
-    current_value = HexCharToNibble(current);
-    if (current_value == -1) {
-      // Skip over non hex characters.
-      current = fgetc(in);
-      continue;
-    }
-
-    switch (state) {
-      case 0:  // Looking for char 1 of 4 in num_bytes.
-        num_bytes = current_value << 4;
-        state = 1;
-        break;
-      case 1:  // Looking for char 2 of 4 in num_bytes.
-        num_bytes += current_value;
-        state = 2;
-        break;
-      case 2:  // Looking for char 3 of 4 in num_bytes.
-        num_bytes += current_value << 12;
-        state = 3;
-        break;
-      case 3:  // Looking for char 4 of 4 in num_bytes.
-        num_bytes += current_value << 8;
-        state = 4;  // Reached the end of num_bytes.
-        byte_index = 0;
-        this->num_bytes_ = num_bytes;
-        break;
-      case 5:
-        this->bytes_[byte_index] = current_value << 4;
-        state = 6;  // Has read the upper nibble of the byte.
-        break;
-      case 6:
-        this->bytes_[byte_index] += current_value;
-        byte_index++;
-        if (byte_index < num_bytes) {
-          state = 5;
-        } else {
-          return;
-        }
-        break;
-      case 7:
-        break;
-    }
     current = fgetc(in);
   }
 }


FIX: Style fixes and removed eronious error messages

--- src/ctrans.c
+++ src/ctrans.c
@@ -50,19 +50,10 @@
 #define NPY_NO_DEPRECATED_API NPY_1_9_API_VERSION
 #include <numpy/arrayobject.h>

-/* If useing threading then import pthreads */
-#ifdef USE_THREADS
-#include <pthread.h>
-#include <unistd.h>
-#endif
-
 #include "ctrans.h"

 /* Computation functions */
 static PyObject* ccdToQ(PyObject *self, PyObject *args, PyObject *kwargs){
-  static char *kwlist[] = { "angles", "mode", "ccd_size", "ccd_pixsize",
-			                      "ccd_cen", "dist", "wavelength",
-			                      "UBinv", NULL };
   PyArrayObject *angles = NULL;
   PyObject *_angles = NULL;
   PyArrayObject *ubinv = NULL;
@@ -81,15 +72,19 @@
   double *ubinvp = NULL;
   double *delgam = NULL;

+  static char *kwlist[] = { "angles", "mode", "ccd_size", "ccd_pixsize",
+			                      "ccd_cen", "dist", "wavelength",
+			                      "UBinv", NULL };
+
   if(!PyArg_ParseTupleAndKeywords(args, kwargs, "Oi(ii)(dd)(dd)ddO", kwlist,
-				  &_angles,
-				  &mode,
-				  &ccd.xSize, &ccd.ySize,
-				  &ccd.xPixSize, &ccd.yPixSize,
-				  &ccd.xCen, &ccd.yCen,
-				  &ccd.dist,
-				  &lambda,
-				  &_ubinv)){
+				                          &_angles,
+				                          &mode,
+				                          &ccd.xSize, &ccd.ySize,
+				                          &ccd.xPixSize, &ccd.yPixSize,
+				                          &ccd.xCen, &ccd.yCen,
+				                          &ccd.dist,
+				                          &lambda,
+				                          &_ubinv)){

     return NULL;
   }
@@ -98,13 +93,11 @@

   angles = (PyArrayObject*)PyArray_FROMANY(_angles, NPY_DOUBLE, 2, 2, NPY_ARRAY_IN_ARRAY);
   if(!angles){
-    PyErr_SetString(PyExc_ValueError, "angles must be a 2-D array of floats");
     goto cleanup;
   }

   ubinv = (PyArrayObject*)PyArray_FROMANY(_ubinv, NPY_DOUBLE, 2, 2, NPY_ARRAY_IN_ARRAY);
   if(!ubinv){
-    PyErr_SetString(PyExc_ValueError, "ubinv must be a 2-D array of floats");
     goto cleanup;
   }

@@ -117,10 +110,8 @@

   qOut = (PyArrayObject*)PyArray_SimpleNew(2, dims, NPY_DOUBLE);
   if(!qOut){
-    PyErr_SetString(PyExc_MemoryError, "Could not allocate memory (qOut)");
     goto cleanup;
   }
-

   anglesp = (double *)PyArray_DATA(angles);
   qOutp = (double *)PyArray_DATA(qOut);
@@ -128,10 +119,8 @@
   // Now create the arrays for delta-gamma pairs
   delgam = (double*)malloc(nimages * ccd.size * sizeof(double) * 2);
   if(!delgam){
-    PyErr_SetString(PyExc_MemoryError, "Could not allocate memory (delgam)");
     goto cleanup;
   }
-

   // Ok now we don't touch Python Object ... Release the GIL
   Py_BEGIN_ALLOW_THREADS
@@ -322,7 +311,6 @@

   gridI = (PyArrayObject*)PyArray_FROMANY(_I, NPY_DOUBLE, 0, 0, NPY_ARRAY_IN_ARRAY);
   if(!gridI){
-    PyErr_SetString(PyExc_MemoryError, "Could not allocate memory (gridI)");
     goto error;
   }

@@ -338,19 +326,16 @@

   gridout = (PyArrayObject*)PyArray_SimpleNew(3, dims, NPY_DOUBLE);
   if(!gridout){
-    PyErr_SetString(PyExc_MemoryError, "Could not allocate memory (gridout)");
     goto error;
   }

   Nout = (PyArrayObject*)PyArray_SimpleNew(3, dims, NPY_ULONG);
   if(!Nout){
-    PyErr_SetString(PyExc_MemoryError, "Could not allocate memory (Nout)");
     goto error;
   }

   stderror = (PyArrayObject*)PyArray_SimpleNew(3, dims, NPY_DOUBLE);
   if(!stderror){
-    PyErr_SetString(PyExc_MemoryError, "Could not allocate memory (stderror)");
     goto error;
   }


recenter in the test transform

recenter in the test transform

--- reg/siftreg.c
+++ reg/siftreg.c
@@ -154,7 +154,7 @@
 				err_exit("load source image\n");
 		}

-		// Apply an affine transformation to the reference image
+                // Make a rotation matrix
 		double ang_deg = 10.0;
 		double ang_rad = ang_deg * UTIL_PI / 180.0;
 		MAT_RM_GET(&A, 0, 0, double) = cos(ang_rad);
@@ -163,7 +163,25 @@
 		MAT_RM_GET(&A, 1, 1, double) = cos(ang_rad);
 		MAT_RM_GET(&A, 2, 2, double) = 1.0;
 		if (Affine_set_mat(&A, &aff_syn))
+			err_exit("set rotation matrix\n");
+
+                // Rotate the center
+                const double xc = ((double) src_temp.nx - 1.0) / 2.0;
+                const double yc = ((double) src_temp.ny - 1.0) / 2.0;
+                const double zc = ((double) src_temp.nz - 1.0) / 2.0;
+                double xtrans, ytrans, ztrans;
+                if (apply_tform_xyz(xc, yc, zc, &xtrans, &ytrans, &ztrans,
+                                        AFFINE, &aff_syn))
+                        err_exit("get center translation");
+
+                // Apply the center translation and update the affine transformation
+                MAT_RM_GET(&A, 0, 3, double) = xtrans - xc;
+                MAT_RM_GET(&A, 1, 3, double) = ytrans - yc;
+                MAT_RM_GET(&A, 2, 3, double) = ztrans - zc;
+		if (Affine_set_mat(&A, &aff_syn))
 			err_exit("set affine matrix\n");
+
+		// Apply an affine transformation to the reference image
 		if (im_inv_transform(&src_temp, &src, AFFINE, &aff_syn))
 			err_exit("apply image transform\n");