diff options
author | mvglasow <michael -at- vonglasow.com> | 2018-08-21 22:41:29 +0200 |
---|---|---|
committer | mvglasow <michael -at- vonglasow.com> | 2018-08-21 22:41:29 +0200 |
commit | 964315b9c3721c1c52796386fdde0ddd83827dd4 (patch) | |
tree | 5eddf211510325f85ed1516f306b020e36a564c0 | |
parent | 3f8d6584a4fa6b0ddfabfb444294d51655ca49ea (diff) | |
parent | 8bfc53427cae358a6b747f9c71d91bcc78e8dd65 (diff) | |
download | navit-964315b9c3721c1c52796386fdde0ddd83827dd4.tar.gz |
Merge branch 'master' into traffic
-rw-r--r-- | .circleci/config.yml | 1 | ||||
-rw-r--r-- | gradle/scripts/git-scm-version.gradle | 24 | ||||
-rw-r--r-- | navit/android/build.gradle | 5 | ||||
-rw-r--r-- | navit/graphics.c | 102 | ||||
-rw-r--r-- | navit/gui/internal/gui_internal.c | 205 | ||||
-rw-r--r-- | navit/maptool/boundaries.c | 14 | ||||
-rw-r--r-- | navit/maptool/google/protobuf-c/protobuf-c.c | 12 | ||||
-rw-r--r-- | navit/maptool/itembin.c | 4 | ||||
-rw-r--r-- | navit/maptool/maptool.c | 4 | ||||
-rw-r--r-- | navit/maptool/osm.c | 162 | ||||
-rw-r--r-- | navit/maptool/osm_protobuf.c | 4 | ||||
-rw-r--r-- | navit/maptool/osm_protobufdb.c | 6 | ||||
-rw-r--r-- | navit/maptool/osm_psql.c | 6 | ||||
-rw-r--r-- | navit/maptool/osm_xml.c | 6 | ||||
-rw-r--r-- | navit/maptool/tile.c | 8 | ||||
-rw-r--r-- | navit/route.c | 4 | ||||
-rw-r--r-- | navit/tools/latlon2bookmark/Makefile | 2 | ||||
-rw-r--r-- | navit/tools/latlon2bookmark/latlon2bookmark.c | 2 | ||||
-rw-r--r-- | navit/util.c | 31 | ||||
-rw-r--r-- | navit/util.h | 1 | ||||
-rw-r--r-- | navit/xslt/android.xslt | 2 |
21 files changed, 420 insertions, 185 deletions
diff --git a/.circleci/config.yml b/.circleci/config.yml index a30fcb5ff..8fb38998c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -56,7 +56,6 @@ jobs: environment: JVM_OPTS: -Xmx3200m GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError"' - ANDROID_NDK_HOME: '/opt/android/ndk/android-ndk-r17b/' steps: - checkout - run: diff --git a/gradle/scripts/git-scm-version.gradle b/gradle/scripts/git-scm-version.gradle new file mode 100644 index 000000000..a0d518a86 --- /dev/null +++ b/gradle/scripts/git-scm-version.gradle @@ -0,0 +1,24 @@ +//THX to https://proandroiddev.com/configuring-android-project-version-name-code-b168952f3323 + +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'org.ajoberstar:grgit:2.3.0' + } +} + +import org.ajoberstar.grgit.Grgit +import java.time.format.DateTimeFormatter + +ext { + git = Grgit.open(currentDir: projectDir) + gitVersionName = git.describe(match: ["v[0-9.rc]*"]) + gitVersionCode = Integer.parseInt(DateTimeFormatter.ofPattern("yyMMddhhmm").format(git.head().dateTime)) +} + +task printVersion() { + println("Version Name: $gitVersionName") + println("Version Code: $gitVersionCode") +} diff --git a/navit/android/build.gradle b/navit/android/build.gradle index ca9dab255..e2e42bc80 100644 --- a/navit/android/build.gradle +++ b/navit/android/build.gradle @@ -1,4 +1,5 @@ apply plugin: 'com.android.application' +apply from: "$project.rootDir/gradle/scripts/git-scm-version.gradle" apply plugin: 'checkstyle' android { @@ -8,8 +9,8 @@ android { applicationId "org.navitproject.navit" minSdkVersion 9 targetSdkVersion 27 - versionCode 1 - versionName "1.0" + versionCode gitVersionCode + versionName gitVersionName testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" ndk { // need for now for 'x86_64' and , 'armeabi' and , 'arm64-v8a' abiFilters 'x86', 'armeabi-v7a' diff --git a/navit/graphics.c b/navit/graphics.c index db94c9ef7..50913eeea 100644 --- a/navit/graphics.c +++ b/navit/graphics.c @@ -1459,30 +1459,6 @@ static int fowler(int dy, int dx) { } return 0; } -static int int_sqrt(unsigned int n) { - unsigned int h, p= 0, q= 1, r= n; - - /* avoid q rollover */ - if(n >= (1<<(sizeof(n)*8-2))) { - q = 1<<(sizeof(n)*8-2); - } else { - while ( q <= n ) { - q <<= 2; - } - q >>= 2; - } - - while ( q != 0 ) { - h = p + q; - p >>= 1; - if ( r >= h ) { - p += q; - r -= h; - } - q >>= 2; - } - return p; -} struct draw_polyline_shape { int wi; @@ -1530,9 +1506,9 @@ static void draw_shape(struct draw_polyline_context *ctx, struct point *pnt, int dys=shape->dy*shape->dy; lscales=lscale*lscale; if (dxs + dys > lscales) - l = int_sqrt(dxs+dys)*lscale; + l = uint_sqrt(dxs+dys)*lscale; else - l = int_sqrt((dxs+dys)*lscales); + l = uint_sqrt((dxs+dys)*lscales); shape->fow=fowler(-shape->dy, shape->dx); dbg(lvl_debug,"fow=%d",shape->fow); @@ -1991,7 +1967,70 @@ static int limit_count(struct coord *c, int count) { return count; } +/** + * @brief Draw a multi-line text next to a specified point @p pref + * + * @param gra The graphics instance on which to draw + * @param fg The graphics color to use to draw the text + * @param bg The graphics background color to use to draw the text + * @param font The font to use to draw the text + * @param pref The position to draw the text (draw at the right and vertically aligned relatively to this point) + * @param label The text to draw (may contain '\n' for multiline text, if so lines will be stacked vertically) + * @param line_spacing The delta between each line (set its value at to least the font text size, to be readable) + */ +static void multiline_label_draw(struct graphics *gra, struct graphics_gc *fg, struct graphics_gc *bg, + struct graphics_font *font, struct point pref, const char *label, int line_spacing) { + + char *input_label=g_strdup(label); + char *label_lines[10]; /* Max 10 lines of text */ + int label_nblines=0; + int label_linepos=0; + char *startline=input_label; + char *endline=startline; + while (endline && *endline!='\0') { + while (*endline!='\0' && *endline!='\n') { /* Search for new line */ + endline=g_utf8_next_char(endline); + } + if (*endline=='\0') + endline=NULL; /* This means we reached the end of string */ + if (endline) /* Test if we got a new line character ('\n') */ + *endline='\0'; /* Terminate string at line ('\n') and print this line */ + label_lines[label_nblines++]=startline; + if (endline==NULL) /* endline is NULL, this was the last line of the multi-line string */ + break; + endline++; /* No need for g_utf8_next_char() here, as we know '\n' is a single byte UTF-8 char */ + startline=endline; /* Start processing next line, by setting startline to its first character */ + } + if (label_nblines>(sizeof(label_lines)/sizeof(char + *))) { /* Does label_nblines overflows the number of entries in array label_lines? */ + dbg(lvl_warning,"Too many lines (%d) in label \"%s\", truncating to %lu", label_nblines, label, + sizeof(label_lines)/sizeof(char *)); + label_nblines=sizeof(label_lines)/sizeof(char *); + } + /* Horizontally, we position the label next to the specified point (on the right handside) */ + pref.x+=1; + /* Vertically, we center the text with respect to specified point */ + pref.y-=(label_nblines*line_spacing)/2; + + /* Parse all stored lines, and display them */ + for (label_linepos=0; label_linepos<label_nblines; label_linepos++) { + gra->meth.draw_text(gra->priv, fg->priv, bg?bg->priv:NULL, font->priv, label_lines[label_linepos], + &pref, 0x10000, 0); + pref.y+=line_spacing; + } + g_free(input_label); +} + +/** + * @brief Draw a displayitem element + * + * This function will invoke the appropriate draw primitive depending on the type of the element to draw + * + * @brief di The displayitem to draw + * @brief dummy Unused + * @brief dc The display_context to use to draw items + */ static void displayitem_draw(struct displayitem *di, void *dummy, struct display_context *dc) { int *width=g_alloca(sizeof(int)*dc->maxlen); struct point *pa=g_alloca(sizeof(struct point)*dc->maxlen); @@ -2048,11 +2087,12 @@ static void displayitem_draw(struct displayitem *di, void *dummy, struct display graphics_gc_set_foreground(gc_background, &e->u.circle.background_color); dc->gc_background=gc_background; } - p.x=pa[0].x+3; - p.y=pa[0].y+10; - if (font) - gra->meth.draw_text(gra->priv, gc->priv, gc_background?gc_background->priv:NULL, font->priv, di->label, &p, 0x10000, 0); - else + if (font) { + /* Set p to the center of the circle */ + p.x=pa[0].x+(e->u.circle.radius/2); + p.y=pa[0].y+(e->u.circle.radius/2); + multiline_label_draw(gra, gc, gc_background, font, p, di->label, e->text_size+1); + } else dbg(lvl_error,"Failed to get font with size %d",e->text_size); } } diff --git a/navit/gui/internal/gui_internal.c b/navit/gui/internal/gui_internal.c index 119d71dc2..a3df6c235 100644 --- a/navit/gui/internal/gui_internal.c +++ b/navit/gui/internal/gui_internal.c @@ -112,6 +112,7 @@ static struct gui_config_settings config_profiles[]= { }; static void gui_internal_cmd_view_in_browser(struct gui_priv *this, struct widget *wm, void *data); +static void gui_internal_prepare_search_results_map(struct gui_priv *this, struct widget *table, struct coord_rect *r); static int gui_internal_is_active_vehicle(struct gui_priv *this, struct vehicle *vehicle); @@ -706,7 +707,12 @@ static void gui_internal_cmd_delete_bookmark(struct gui_priv *this, struct widge /** - * Get a utf-8 string, return the same prepared for case insensitive search. Result should be g_free()d after use. + * @brief Remove the case in a string + * + * @warning Result should be g_free()d after use. + * + * @param s The input utf-8 string + * @return An equivalent string prepared for case insensitive search */ char *removecase(char *s) { char *r; @@ -714,7 +720,21 @@ char *removecase(char *s) { return r; } +/** + * @brief Apply the command "View on Map", centers the map on the selected point and highlight this point using + * type_found_item style + * + * @param this The GUI context + * @param wm The widget that points to this function as a callback + * @param data Private data provided during callback (unused) + */ static void gui_internal_cmd_view_on_map(struct gui_priv *this, struct widget *wm, void *data) { + + struct widget *w; + struct widget *wr; + struct widget *wi; + char *label; + if (wm->item.type != type_none) { enum item_type type; if (wm->item.type < type_line) @@ -725,6 +745,22 @@ static void gui_internal_cmd_view_on_map(struct gui_priv *this, struct widget *w type=type_selected_area; graphics_clear_selection(this->gra, NULL); graphics_add_selection(this->gra, &wm->item, type, NULL); + } else { + if (wm->item.priv_data) + label = wm->item.priv_data; /* Use the label of the point to view on map */ + else + label = g_strdup(""); + w = gui_internal_widget_table_new(this, 0, 0); /* Create a basic table */ + gui_internal_widget_append(w,wr=gui_internal_widget_table_row_new(this,0)); /* In this table, add one row */ + gui_internal_widget_append(wr,wi=gui_internal_box_new_with_label(this,0, + label)); /* That row contains a widget of type widget_box */ + wi->name = label; /* Use the label of the point to view on map */ + wi->c.x=wm->c.x; /* Use the coordinates of the point to place it on the map */ + wi->c.y=wm->c.y; + gui_internal_prepare_search_results_map(this, w, NULL); + g_free(label); + wi->name = NULL; + gui_internal_widget_destroy(this, w); } navit_set_center(this->nav, &wm->c, 1); gui_internal_prune_menu(this, NULL); @@ -854,29 +890,22 @@ static void gui_internal_cmd_view_in_browser(struct gui_priv *this, struct widge } } - -/* - * @brief Transfers search results to a map. +/** + * @brief Get the search result map (and create it if it does not exist) * - * @param this The graphics context. - * @param wm called widget. - * @param data event data (pointer to the table widget containing results, or NULL to clean the result map without adding any new data). + * @param this The GUI context + * + * @return A pointer to the map named "search_results" or NULL if there wasa failure */ -static void gui_internal_cmd_results_to_map(struct gui_priv *this, struct widget *wm, void *data) { - struct widget *w; +static struct map *get_search_results_map(struct gui_priv *this) { + struct mapset *ms; struct map *map; - struct map_rect *mr; - struct item *item; - GList *l; - struct coord_rect r; - struct attr a; - int count; ms=navit_get_mapset(this->nav); if(!ms) - return; + return NULL; map=mapset_get_map_by_name(ms, "search_results"); if(!map) { @@ -912,9 +941,94 @@ static void gui_internal_cmd_results_to_map(struct gui_priv *this, struct widget for(i=0; attrs[i]; i++) g_free(attrs[i]); + } + return map; +} +/** + * @brief Optimizes the format of a string, adding carriage returns so that when displayed, the result text zone is roughly as wide as high + * + * @param[in,out] s The string to proces (will be modified by this function, but length will be unchanged) + */ +static void square_shape_str(char *s) { + char *c; + char *last_break; + unsigned int max_cols = 0; + unsigned int cur_cols = 0; + unsigned int max_rows = 0; + unsigned int surface; + unsigned int target_cols; + + if (!s) + return; + for (c=s; *c!='\0'; c++) { + if (*c==' ') { + if (max_cols < cur_cols) + max_cols = cur_cols; + cur_cols = 0; + max_rows++; + } else + cur_cols++; + } + if (max_cols < cur_cols) + max_cols = cur_cols; + if (cur_cols) /* If last line does not end with CR, add it to line numbers anyway */ + max_rows++; + /* Give twice more room for rows (hence the factor 2 below) + * This will render as a rectangular shape, taking more horizontal space than vertical */ + surface = max_rows * 2 * max_cols; + target_cols = uint_sqrt(surface); + + if (target_cols < max_cols) + target_cols = max_cols; + + target_cols = target_cols + target_cols/10; /* Allow 10% extra on columns */ + dbg(lvl_debug, "square_shape_str(): analyzing input text=\"%s\". max_rows=%u, max_cols=%u, surface=%u, target_cols=%u", + s, max_rows, max_cols, max_rows * 2 * max_cols, target_cols); + + cur_cols = 0; + last_break = NULL; + for (c=s; *c!='\0'; c++) { + if (*c==' ') { + if (cur_cols>=target_cols) { /* This line is too long, break at the previous non alnum character */ + if (last_break) { + *last_break = + '\n'; /* Replace the previous non alnum character with a line break, this creates a new line and prevents the previous line from being too long */ + cur_cols = c-last_break; + } + } + last_break = c; /* Record this position as a candidate to insert a line break */ + } + cur_cols++; } + if (cur_cols>=target_cols && last_break) { + *last_break = + '\n'; /* Replace the previous non alnum character with a line break, this creates a new line and prevents the previous line from being too long */ + } + + dbg(lvl_debug, "square_shape_str(): output text=\"%s\"", s); +} + +/** + * @brief Create a map rect highlighting one of multiple points provided in argument @data and displayed using + * the style type_found_item (name for each point will also be displayed aside) + * + * @param this The GUI context + * @param table A table widget or any of its descendants. The table contain results to place on the map. + * Providing NULL here will remove all previous results from the map. + * @param[out] r The minimum rect focused to contain all results placed on the map (or unchanged if r==NULL) + */ +static void gui_internal_prepare_search_results_map(struct gui_priv *this, struct widget *table, struct coord_rect *r) { + struct widget *w; + struct map *map; + struct map_rect *mr; + struct item *item; + GList *l; + struct attr a; + int count; + char *name_label; + map = get_search_results_map(this); if(!map) return; @@ -931,8 +1045,8 @@ static void gui_internal_cmd_results_to_map(struct gui_priv *this, struct widget this->results_map_population=0; - /* Find the table to pupulate the map */ - for(w=data; w && w->type!=widget_table; w=w->parent); + /* Find the table to populate the map */ + for(w=table; w && w->type!=widget_table; w=w->parent); if(!w) { map_rect_destroy(mr); @@ -957,12 +1071,16 @@ static void gui_internal_cmd_results_to_map(struct gui_priv *this, struct widget c.y=wi->c.y; item_coord_set(it, &c, 1, change_mode_modify); a.type=attr_label; - a.u.str=wi->name; + name_label = g_strdup(wi->name); + square_shape_str(name_label); + a.u.str=name_label; item_attr_set(it, &a, change_mode_modify); - if(!count++) - r.lu=r.rl=c; - else - coord_rect_extend(&r,&c); + if (r) { + if(!count++) + r->lu=r->rl=c; + else + coord_rect_extend(r,&c); + } } } } @@ -971,18 +1089,35 @@ static void gui_internal_cmd_results_to_map(struct gui_priv *this, struct widget return; a.type=attr_orientation; a.u.num=0; - navit_set_attr(this->nav,&a); - navit_zoom_to_rect(this->nav,&r); - gui_internal_prune_menu(this, NULL); + navit_set_attr(this->nav,&a); /* Set orientation to North */ + if (r) { + navit_zoom_to_rect(this->nav,r); + gui_internal_prune_menu(this, NULL); + } this->results_map_population=count; } +/** + * @brief Apply the command "Show results on the map", highlighting one of multiple points using + * type_found_item style (with their respective name placed aside) + * + * @param this The GUI context + * @param wm The widget that called us + * @param data Private data provided during callback (should be a pointer to the table widget containing results, + * or NULL to remove all previous results from the map). + */ +static void gui_internal_cmd_results_to_map(struct gui_priv *this, struct widget *wm, void *data) { + struct coord_rect r; + + gui_internal_prepare_search_results_map(this, (struct widget *)data, &r); +} + /* - * @brief Removes search results from a map. + * @brief Removes all existing search results from a map. * - * @param this The graphics context. - * @param wm called widget. - * @param data event data + * @param this The GUI context + * @param wm The widget that called us + * @param data Private data (unused). */ static void gui_internal_cmd_results_map_clean(struct gui_priv *this, struct widget *wm, void *data) { gui_internal_cmd_results_to_map(this,wm,NULL); @@ -1025,10 +1160,10 @@ static void gui_internal_cmd_delete_waypoint(struct gui_priv *this, struct widge * argument or in WGS84 coordinates (i.e. latitude and longitude in degrees) via the {@code g_in} * argument. One of these must be supplied, the other should be {@code NULL}. * - * @param this The internal GUI instance + * @param this The GUI context * @param pc_in Projected coordinates of the position * @param g_in WGS84 coordinates of the position - * @param wm + * @param wm The widget that points to this function as a callback * @param name The display name for the position * @param flags Flags specifying the operations available from the GUI */ @@ -1204,10 +1339,12 @@ void gui_internal_cmd_position_do(struct gui_priv *this, struct pcoord *pc_in, s image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill, gui_internal_cmd_view_on_map, NULL)); wbc->c=pc; - if ((flags & 4) && wm) + if ((flags & 4) && wm) { wbc->item=wm->item; - else + } else { wbc->item.type=type_none; + wbc->item.priv_data = g_strdup(name); /* Will be freed up by gui_internal_cmd_view_on_map() */ + } } if(flags & 256 && this->results_map_population) { gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this, diff --git a/navit/maptool/boundaries.c b/navit/maptool/boundaries.c index 4f5967ae8..e7dc90123 100644 --- a/navit/maptool/boundaries.c +++ b/navit/maptool/boundaries.c @@ -79,10 +79,10 @@ static GList *process_boundaries_setup(FILE *boundaries, struct relations *relat if(!iso) iso=osm_tag_value(ib, "iso3166-1:alpha2"); - if (admin_level && !strcmp(admin_level, "2")) { + if (!g_strcmp0(admin_level, "2")) { if(!iso) { char *int_name=osm_tag_value(ib,"int_name"); - if(int_name && !strcmp(int_name,"France")) + if(!g_strcmp0(int_name,"France")) iso="FR"; } if (iso) { @@ -111,17 +111,17 @@ static GList *process_boundaries_setup(FILE *boundaries, struct relations *relat rolestr=member+read; if(member_type==rel_member_node) { - if(!strcmp(rolestr,"admin_centre") || !strcmp(rolestr,"admin_center")) + if(!g_strcmp0(rolestr,"admin_centre") || !g_strcmp0(rolestr,"admin_center")) boundary->admin_centre=osm_id; } if(member_type==rel_member_way) { enum geom_poly_segment_type role; - if (!strcmp(rolestr,"outer") || !strcmp(rolestr,"exclave")) { + if (!g_strcmp0(rolestr,"outer") || !g_strcmp0(rolestr,"exclave")) { has_outer_ways=1; role=geom_poly_segment_type_way_outer; - } else if (!strcmp(rolestr,"inner") || !strcmp(rolestr,"enclave")) + } else if (!g_strcmp0(rolestr,"inner") || !g_strcmp0(rolestr,"enclave")) role=geom_poly_segment_type_way_inner; - else if (!strcmp(rolestr,"")) + else if (!g_strcmp0(rolestr,"")) role=geom_poly_segment_type_way_unknown; else { osm_warning("relation",item_bin_get_relationid(ib),0,"Unknown role %s in member ",rolestr); @@ -131,7 +131,7 @@ static GList *process_boundaries_setup(FILE *boundaries, struct relations *relat relations_add_relation_member_entry(relations, relations_func, boundary, (gpointer)role, rel_member_way, osm_id); } if(member_type==rel_member_relation) { - if (!strcmp(rolestr,"outer") || !strcmp(rolestr,"exclave") || !strcmp(rolestr,"inner") || !strcmp(rolestr,"enclave")) + if (!g_strcmp0(rolestr,"outer") || !g_strcmp0(rolestr,"exclave") || !g_strcmp0(rolestr,"inner") || !g_strcmp0(rolestr,"enclave")) has_subrelations++; } } diff --git a/navit/maptool/google/protobuf-c/protobuf-c.c b/navit/maptool/google/protobuf-c/protobuf-c.c index ab0b31e5a..a7a8516f2 100644 --- a/navit/maptool/google/protobuf-c/protobuf-c.c +++ b/navit/maptool/google/protobuf-c/protobuf-c.c @@ -2192,7 +2192,7 @@ protobuf_c_enum_descriptor_get_value_by_name unsigned start = 0, count = desc->n_value_names; while (count > 1) { unsigned mid = start + count / 2; - int rv = strcmp (desc->values_by_name[mid].name, name); + int rv = g_strcmp0(desc->values_by_name[mid].name, name); if (rv == 0) return desc->values + desc->values_by_name[mid].index; else if (rv < 0) { @@ -2203,7 +2203,7 @@ protobuf_c_enum_descriptor_get_value_by_name } if (count == 0) return NULL; - if (strcmp (desc->values_by_name[start].name, name) == 0) + if (g_strcmp0(desc->values_by_name[start].name, name) == 0) return desc->values + desc->values_by_name[start].index; return NULL; } @@ -2227,7 +2227,7 @@ protobuf_c_message_descriptor_get_field_by_name unsigned mid = start + count / 2; int rv; field = desc->fields + desc->fields_sorted_by_name[mid]; - rv = strcmp (field->name, name); + rv = g_strcmp0(field->name, name); if (rv == 0) return field; else if (rv < 0) { @@ -2239,7 +2239,7 @@ protobuf_c_message_descriptor_get_field_by_name if (count == 0) return NULL; field = desc->fields + desc->fields_sorted_by_name[start]; - if (strcmp (field->name, name) == 0) + if (g_strcmp0(field->name, name) == 0) return field; return NULL; } @@ -2265,7 +2265,7 @@ protobuf_c_service_descriptor_get_method_by_name unsigned mid = start + count / 2; unsigned mid_index = desc->method_indices_by_name[mid]; const char *mid_name = desc->methods[mid_index].name; - int rv = strcmp (mid_name, name); + int rv = g_strcmp0(mid_name, name); if (rv == 0) return desc->methods + desc->method_indices_by_name[mid]; if (rv < 0) { @@ -2277,7 +2277,7 @@ protobuf_c_service_descriptor_get_method_by_name } if (count == 0) return NULL; - if (strcmp (desc->methods[desc->method_indices_by_name[start]].name, name) == 0) + if (g_strcmp0(desc->methods[desc->method_indices_by_name[start]].name, name) == 0) return desc->methods + desc->method_indices_by_name[start]; return NULL; } diff --git a/navit/maptool/itembin.c b/navit/maptool/itembin.c index a0c40138b..6f1328355 100644 --- a/navit/maptool/itembin.c +++ b/navit/maptool/itembin.c @@ -458,7 +458,7 @@ static int item_bin_sort_compare(const void *p1, const void *p2) { if(attr1&&attr2) { s1=(char *)(attr1+1); s2=(char *)(attr2+1); - ret=strcmp(s1,s2); + ret=g_strcmp0(s1,s2); if(ret) return ret; } @@ -475,7 +475,7 @@ static int item_bin_sort_compare(const void *p1, const void *p2) { s1=linguistics_casefold(s1); s2=linguistics_casefold(s2); - ret=strcmp(s1, s2); + ret=g_strcmp0(s1, s2); g_free(s1); g_free(s2); diff --git a/navit/maptool/maptool.c b/navit/maptool/maptool.c index 492deb1ac..422bc96bf 100644 --- a/navit/maptool/maptool.c +++ b/navit/maptool/maptool.c @@ -755,7 +755,7 @@ static void maptool_generate_tiles(struct maptool_params *p, char *suffix, char } zipnum=zip_get_zipnum(zip_info); tilesdir=tempfile(suffix,"tilesdir",1); - if (!strcmp(suffix,ch_suffix)) { /* Makes compiler happy due to bug 35903 in gcc */ + if (!g_strcmp0(suffix,ch_suffix)) { /* Makes compiler happy due to bug 35903 in gcc */ ch_generate_tiles(suffix0,suffix,tilesdir,zip_info); } else { for (f = 0 ; f < filename_count ; f++) @@ -795,7 +795,7 @@ static void maptool_assemble_map(struct maptool_params *p, char *suffix, char ** } index_init(zip_info, 1); } - if (!strcmp(suffix,ch_suffix)) { /* Makes compiler happy due to bug 35903 in gcc */ + if (!g_strcmp0(suffix,ch_suffix)) { /* Makes compiler happy due to bug 35903 in gcc */ ch_assemble_map(suffix0,suffix,zip_info); } else { for (f = 0 ; f < filename_count ; f++) { diff --git a/navit/maptool/osm.c b/navit/maptool/osm.c index dc0e49d58..e36234775 100644 --- a/navit/maptool/osm.c +++ b/navit/maptool/osm.c @@ -979,29 +979,29 @@ static int node_is_tagged; static void relation_add_tag(char *k, char *v); static int access_value(char *v) { - if (!strcmp(v,"1")) + if (!g_strcmp0(v,"1")) return 1; - if (!strcmp(v,"yes")) + if (!g_strcmp0(v,"yes")) return 1; - if (!strcmp(v,"designated")) + if (!g_strcmp0(v,"designated")) return 1; - if (!strcmp(v,"official")) + if (!g_strcmp0(v,"official")) return 1; - if (!strcmp(v,"permissive")) + if (!g_strcmp0(v,"permissive")) return 1; - if (!strcmp(v,"0")) + if (!g_strcmp0(v,"0")) return 2; - if (!strcmp(v,"no")) + if (!g_strcmp0(v,"no")) return 2; - if (!strcmp(v,"agricultural")) + if (!g_strcmp0(v,"agricultural")) return 2; - if (!strcmp(v,"forestry")) + if (!g_strcmp0(v,"forestry")) return 2; - if (!strcmp(v,"private")) + if (!g_strcmp0(v,"private")) return 2; - if (!strcmp(v,"delivery")) + if (!g_strcmp0(v,"delivery")) return 2; - if (!strcmp(v,"destination")) + if (!g_strcmp0(v,"destination")) return 2; return 3; } @@ -1014,31 +1014,31 @@ void osm_add_tag(char *k, char *v) { relation_add_tag(k,v); return; } - if (! strcmp(k,"ele")) { + if (! g_strcmp0(k,"ele")) { attr_strings_save(attr_string_label, v); level=9; } - if (! strcmp(k,"time")) + if (! g_strcmp0(k,"time")) level=9; - if (! strcmp(k,"created_by")) + if (! g_strcmp0(k,"created_by")) level=9; - if (! strncmp(k,"tiger:",6) || !strcmp(k,"AND_nodes")) + if (! strncmp(k,"tiger:",6) || !g_strcmp0(k,"AND_nodes")) level=9; - if (! strcmp(k,"converted_by") || ! strcmp(k,"source")) + if (! g_strcmp0(k,"converted_by") || ! g_strcmp0(k,"source")) level=8; if (! strncmp(k,"osmarender:",11) || !strncmp(k,"svg:",4)) level=8; - if (! strcmp(k,"layer")) + if (! g_strcmp0(k,"layer")) level=7; if (! strcasecmp(v,"true") || ! strcasecmp(v,"yes")) v="1"; if (! strcasecmp(v,"false") || ! strcasecmp(v,"no")) v="0"; - if (! strcmp(k,"oneway")) { - if (!strcmp(v,"1")) { + if (! g_strcmp0(k,"oneway")) { + if (!g_strcmp0(v,"1")) { flags[0] |= AF_ONEWAY | AF_ROUNDABOUT_VALID; } - if (! strcmp(v,"-1")) { + if (! g_strcmp0(v,"-1")) { flags[0] |= AF_ONEWAYREV | AF_ROUNDABOUT_VALID; } if (!in_way) @@ -1046,11 +1046,11 @@ void osm_add_tag(char *k, char *v) { else level=5; } - if (! strcmp(k,"junction")) { - if (! strcmp(v,"roundabout")) + if (! g_strcmp0(k,"junction")) { + if (! g_strcmp0(v,"roundabout")) flags[0] |= AF_ONEWAY | AF_ROUNDABOUT | AF_ROUNDABOUT_VALID; } - if (! strcmp(k,"maxspeed")) { + if (! g_strcmp0(k,"maxspeed")) { if (strstr(v, "mph")) { maxspeed_attr_value = (int)floor(atof(v) * 1.609344); } else { @@ -1060,183 +1060,183 @@ void osm_add_tag(char *k, char *v) { flags[0] |= AF_SPEED_LIMIT; level=5; } - if (! strcmp(k,"toll")) { - if (!strcmp(v,"1")) { + if (! g_strcmp0(k,"toll")) { + if (!g_strcmp0(v,"1")) { flags[0] |= AF_TOLL; } } - if (! strcmp(k,"access")) { - if (strcmp(v,"destination")) + if (! g_strcmp0(k,"access")) { + if (g_strcmp0(v,"destination")) flagsa[access_value(v)] |= AF_DANGEROUS_GOODS|AF_EMERGENCY_VEHICLES|AF_TRANSPORT_TRUCK|AF_DELIVERY_TRUCK|AF_PUBLIC_BUS|AF_TAXI|AF_HIGH_OCCUPANCY_CAR|AF_CAR|AF_MOTORCYCLE|AF_MOPED|AF_HORSE|AF_BIKE|AF_PEDESTRIAN; else flags[0] |= AF_THROUGH_TRAFFIC_LIMIT; - if (! strcmp(v,"hov")) + if (! g_strcmp0(v,"hov")) flags[0] |= AF_HIGH_OCCUPANCY_CAR_ONLY; level=5; } - if (! strcmp(k,"vehicle")) { + if (! g_strcmp0(k,"vehicle")) { flags[access_value(v)] |= AF_DANGEROUS_GOODS|AF_EMERGENCY_VEHICLES|AF_TRANSPORT_TRUCK|AF_DELIVERY_TRUCK|AF_PUBLIC_BUS|AF_TAXI|AF_HIGH_OCCUPANCY_CAR|AF_CAR|AF_MOTORCYCLE|AF_MOPED|AF_BIKE; level=5; } - if (! strcmp(k,"motor_vehicle")) { + if (! g_strcmp0(k,"motor_vehicle")) { flags[access_value(v)] |= AF_DANGEROUS_GOODS|AF_EMERGENCY_VEHICLES|AF_TRANSPORT_TRUCK|AF_DELIVERY_TRUCK|AF_PUBLIC_BUS|AF_TAXI|AF_HIGH_OCCUPANCY_CAR|AF_CAR|AF_MOTORCYCLE|AF_MOPED; level=5; } - if (! strcmp(k,"bicycle")) { + if (! g_strcmp0(k,"bicycle")) { flags[access_value(v)] |= AF_BIKE; level=5; } - if (! strcmp(k,"foot")) { + if (! g_strcmp0(k,"foot")) { flags[access_value(v)] |= AF_PEDESTRIAN; level=5; } - if (! strcmp(k,"horse")) { + if (! g_strcmp0(k,"horse")) { flags[access_value(v)] |= AF_HORSE; level=5; } - if (! strcmp(k,"moped")) { + if (! g_strcmp0(k,"moped")) { flags[access_value(v)] |= AF_MOPED; level=5; } - if (! strcmp(k,"motorcycle")) { + if (! g_strcmp0(k,"motorcycle")) { flags[access_value(v)] |= AF_MOTORCYCLE; level=5; } - if (! strcmp(k,"motorcar")) { + if (! g_strcmp0(k,"motorcar")) { flags[access_value(v)] |= AF_CAR; level=5; } - if (! strcmp(k,"hov")) { + if (! g_strcmp0(k,"hov")) { flags[access_value(v)] |= AF_HIGH_OCCUPANCY_CAR; level=5; } - if (! strcmp(k,"bus")) { + if (! g_strcmp0(k,"bus")) { flags[access_value(v)] |= AF_PUBLIC_BUS; level=5; } - if (! strcmp(k,"taxi")) { + if (! g_strcmp0(k,"taxi")) { flags[access_value(v)] |= AF_TAXI; level=5; } - if (! strcmp(k,"goods")) { + if (! g_strcmp0(k,"goods")) { flags[access_value(v)] |= AF_DELIVERY_TRUCK; level=5; } - if (! strcmp(k,"hgv")) { + if (! g_strcmp0(k,"hgv")) { flags[access_value(v)] |= AF_TRANSPORT_TRUCK; level=5; } - if (! strcmp(k,"emergency")) { + if (! g_strcmp0(k,"emergency")) { flags[access_value(v)] |= AF_EMERGENCY_VEHICLES; level=5; } - if (! strcmp(k,"hazmat")) { + if (! g_strcmp0(k,"hazmat")) { flags[access_value(v)] |= AF_DANGEROUS_GOODS; level=5; } - if (! strcmp(k,"tunnel") && !strcmp(v,"1")) { + if (! g_strcmp0(k,"tunnel") && !g_strcmp0(v,"1")) { flags[0] |= AF_UNDERGROUND; } - if (! strcmp(k,"note")) + if (! g_strcmp0(k,"note")) level=5; - if (! strcmp(k,"name")) { + if (! g_strcmp0(k,"name")) { attr_strings_save(attr_string_label, v); level=5; } - if (! strcmp(k,"addr:email")) { + if (! g_strcmp0(k,"addr:email")) { attr_strings_save(attr_string_email, v); level=5; } - if (! strcmp(k,"addr:suburb")) { + if (! g_strcmp0(k,"addr:suburb")) { attr_strings_save(attr_string_district_name, v); level=5; } - if (! strcmp(k,"addr:housenumber")) { + if (! g_strcmp0(k,"addr:housenumber")) { attr_strings_save(attr_string_house_number, v); level=5; } - if (! strcmp(k,"addr:street")) { + if (! g_strcmp0(k,"addr:street")) { attr_strings_save(attr_string_street_name, v); level=5; } - if (! strcmp(k,"phone")) { + if (! g_strcmp0(k,"phone")) { attr_strings_save(attr_string_phone, v); level=5; } - if (! strcmp(k,"fax")) { + if (! g_strcmp0(k,"fax")) { attr_strings_save(attr_string_fax, v); level=5; } - if (! strcmp(k,"postal_code")) { + if (! g_strcmp0(k,"postal_code")) { attr_strings_save(attr_string_postal, v); level=5; } - if (! strcmp(k,"addr:postcode") && !attr_strings[attr_string_postal]) { + if (! g_strcmp0(k,"addr:postcode") && !attr_strings[attr_string_postal]) { attr_strings_save(attr_string_postal, v); level=5; } - if (! strcmp(k,"openGeoDB:postal_codes") && !attr_strings[attr_string_postal]) { + if (! g_strcmp0(k,"openGeoDB:postal_codes") && !attr_strings[attr_string_postal]) { attr_strings_save(attr_string_postal, v); level=5; } - if (! strcmp(k,"population")) { + if (! g_strcmp0(k,"population")) { attr_strings_save(attr_string_population, v); level=5; } - if (! strcmp(k,"openGeoDB:population") && !attr_strings[attr_string_population]) { + if (! g_strcmp0(k,"openGeoDB:population") && !attr_strings[attr_string_population]) { attr_strings_save(attr_string_population, v); level=5; } - if ((! strcmp(k,"ref")) || (! strcmp(k,"destination:ref"))) { + if ((! g_strcmp0(k,"ref")) || (! g_strcmp0(k,"destination:ref"))) { if (in_way) attr_strings_save(attr_string_street_name_systematic, v); /* for exit number of highway_exit poi */ else attr_strings_save(attr_string_ref, v); level=5; } - if (! strcmp(k,"nat_ref")) { + if (! g_strcmp0(k,"nat_ref")) { if (in_way) attr_strings_save(attr_string_street_name_systematic_nat, v); level=5; } - if (! strcmp(k,"int_ref")) { + if (! g_strcmp0(k,"int_ref")) { if (in_way) attr_strings_save(attr_string_street_name_systematic_int, v); level=5; } - if (! strcmp(k,"destination")) { + if (! g_strcmp0(k,"destination")) { if (in_way) attr_strings_save(attr_string_street_destination, v); level=5; } - if (! strcmp(k,"destination:forward")) { + if (! g_strcmp0(k,"destination:forward")) { if (in_way) attr_strings_save(attr_string_street_destination_forward, v); level=5; } - if (! strcmp(k,"destination:backward")) { + if (! g_strcmp0(k,"destination:backward")) { if (in_way) attr_strings_save(attr_string_street_destination_backward, v); level=5; } - if (! strcmp(k,"exit_to")) { + if (! g_strcmp0(k,"exit_to")) { attr_strings_save(attr_string_exit_to, v); level=5; } - if (! strcmp(k,"openGeoDB:is_in")) { + if (! g_strcmp0(k,"openGeoDB:is_in")) { if (!is_in_buffer[0]) g_strlcpy(is_in_buffer, v, sizeof(is_in_buffer)); level=5; } - if (! strcmp(k,"is_in")) { + if (! g_strcmp0(k,"is_in")) { if (!is_in_buffer[0]) g_strlcpy(is_in_buffer, v, sizeof(is_in_buffer)); level=5; } - if (! strcmp(k,"is_in:country")) { + if (! g_strcmp0(k,"is_in:country")) { /** * Sometimes there is no is_in tag, only is_in:country. * I put this here so it can be overwritten by the previous if clause if there IS an is_in tag. @@ -1244,7 +1244,7 @@ void osm_add_tag(char *k, char *v) { g_strlcpy(is_in_buffer, v, sizeof(is_in_buffer)); level=5; } - if (! strcmp(k,"place_county")) { + if (! g_strcmp0(k,"place_county")) { /** * Ireland uses the place_county OSM tag to describe what county a town is in. * This would be equivalent to is_in: Town; Locality; Country @@ -1256,7 +1256,7 @@ void osm_add_tag(char *k, char *v) { attr_strings_save(attr_string_county_name, v); level=5; } - if (! strcmp(k,"gnis:ST_alpha")) { + if (! g_strcmp0(k,"gnis:ST_alpha")) { /* assume a gnis tag means it is part of the USA: http://en.wikipedia.org/wiki/Geographic_Names_Information_System many US towns do not have is_in tags @@ -1264,7 +1264,7 @@ void osm_add_tag(char *k, char *v) { g_strlcpy(is_in_buffer, "USA", sizeof(is_in_buffer)); level=5; } - if (! strcmp(k,"lanes")) { + if (! g_strcmp0(k,"lanes")) { level=5; } if (attr_debug_level >= level) { @@ -1619,15 +1619,15 @@ void osm_end_relation(struct maptool_osm *osm) { } else type=type_none; - if ((!strcmp(relation_type, "multipolygon") || !strcmp(relation_type, "boundary")) && (boundary || type!=type_none)) { + if ((!g_strcmp0(relation_type, "multipolygon") || !g_strcmp0(relation_type, "boundary")) && (boundary || type!=type_none)) { item_bin_write(tmp_item_bin, osm->boundaries); } - if (!strcmp(relation_type, "restriction") && (tmp_item_bin->type == type_street_turn_restriction_no + if (!g_strcmp0(relation_type, "restriction") && (tmp_item_bin->type == type_street_turn_restriction_no || tmp_item_bin->type == type_street_turn_restriction_only)) item_bin_write(tmp_item_bin, osm->turn_restrictions); - if (!strcmp(relation_type, "associatedStreet") ) + if (!g_strcmp0(relation_type, "associatedStreet") ) item_bin_write(tmp_item_bin, osm->associated_streets); attr_longest_match_clear(); @@ -1645,10 +1645,10 @@ void osm_add_member(enum relation_member_type type, osmid ref, char *role) { static void relation_add_tag(char *k, char *v) { int add_tag=1; - if (!strcmp(k,"type")) { + if (!g_strcmp0(k,"type")) { g_strlcpy(relation_type, v, sizeof(relation_type)); add_tag=0; - } else if (!strcmp(k,"restriction")) { + } else if (!g_strcmp0(k,"restriction")) { if (!strncmp(v,"no_",3)) { tmp_item_bin->type=type_street_turn_restriction_no; add_tag=0; @@ -1659,11 +1659,11 @@ static void relation_add_tag(char *k, char *v) { tmp_item_bin->type=type_none; osm_warning("relation", osmid_attr_value, 0, "Unknown restriction %s\n",v); } - } else if (!strcmp(k,"boundary")) { - if (!strcmp(v,"administrative") || !strcmp(v,"postal_code")) { + } else if (!g_strcmp0(k,"boundary")) { + if (!g_strcmp0(v,"administrative") || !g_strcmp0(v,"postal_code")) { boundary=1; } - } else if (!strcmp(k,"ISO3166-1") || !strcmp(k,"ISO3166-1:alpha2")) { + } else if (!g_strcmp0(k,"ISO3166-1") || !g_strcmp0(k,"ISO3166-1:alpha2")) { g_strlcpy(iso_code, v, sizeof(iso_code)); } if (add_tag) { @@ -2294,7 +2294,7 @@ static int search_relation_member(struct item_bin *ib, char *role, struct relati while ((str=item_bin_get_attr(ib, attr_osm_member, str))) { parse_relation_member_string(str, memb); count++; - if (!strcmp(memb->role, role) && (!min_count || *min_count < count)) { + if (!g_strcmp0(memb->role, role) && (!min_count || *min_count < count)) { if (min_count) *min_count=count; return 1; @@ -3276,7 +3276,7 @@ void write_countrydir(struct zip_info *zip_info, int max_index_size) { - adding new tile would make index part too big, or - item just read belongs to a different tile than the previous one, then close existing output file, put reference to the country index tile.*/ - if(out && (!r || (partsize && ((partsize+ibsize)>max_index_size)) || strcmp(tileprev,tilecur)) ) { + if(out && (!r || (partsize && ((partsize+ibsize)>max_index_size)) || g_strcmp0(tileprev,tilecur)) ) { partsize=ftello(out); fclose(out); out=NULL; diff --git a/navit/maptool/osm_protobuf.c b/navit/maptool/osm_protobuf.c index 9ee8c18f3..b6af3adef 100644 --- a/navit/maptool/osm_protobuf.c +++ b/navit/maptool/osm_protobuf.c @@ -267,9 +267,9 @@ int map_collect_data_osm_protobuf(FILE *in, struct maptool_osm *osm) { while ((header=read_header(in))) { blob=read_blob(header, in, buffer); data=uncompress_blob(blob); - if (!strcmp(header->type,"OSMHeader")) { + if (!g_strcmp0(header->type,"OSMHeader")) { process_osmheader(blob, data); - } else if (!strcmp(header->type,"OSMData")) { + } else if (!g_strcmp0(header->type,"OSMData")) { process_osmdata(blob, data, osm); } else { printf("skipping fileblock of unknown type '%s'\n", header->type); diff --git a/navit/maptool/osm_protobufdb.c b/navit/maptool/osm_protobufdb.c index 0edafe62d..79897eafb 100644 --- a/navit/maptool/osm_protobufdb.c +++ b/navit/maptool/osm_protobufdb.c @@ -638,11 +638,11 @@ static int osm_protobufdb_parse_member(struct osm_protobufdb_context *ctx, char return 0; if (!osm_xml_get_attribute(str, "role", role_buffer, BUFFER_SIZE)) return 0; - if (!strcmp(type_buffer,"node")) + if (!g_strcmp0(type_buffer,"node")) type=0; - else if (!strcmp(type_buffer,"way")) + else if (!g_strcmp0(type_buffer,"way")) type=1; - else if (!strcmp(type_buffer,"relation")) + else if (!g_strcmp0(type_buffer,"relation")) type=2; if (ctx->in_relation) { r->roles_sid=g_realloc(r->roles_sid, (r->n_roles_sid+1)*sizeof(r->roles_sid[0])); diff --git a/navit/maptool/osm_psql.c b/navit/maptool/osm_psql.c index 554341fde..a8dac6914 100644 --- a/navit/maptool/osm_psql.c +++ b/navit/maptool/osm_psql.c @@ -233,13 +233,13 @@ int map_collect_data_osm_db(char *dbstr, struct maptool_osm *osm) { long member_relation_id=atol(PQgetvalue(member, k, 0)); if (member_relation_id == id) { int relmember_type=0; //type unknown - if (!strcmp(PQgetvalue(member,k, 2),"W")) { + if (!g_strcmp0(PQgetvalue(member,k, 2),"W")) { relmember_type=2; } else { - if (!strcmp(PQgetvalue(member,k, 2),"N")) { + if (!g_strcmp0(PQgetvalue(member,k, 2),"N")) { relmember_type=1; } else { - if (!strcmp(PQgetvalue(member,k, 2),"R")) { + if (!g_strcmp0(PQgetvalue(member,k, 2),"R")) { relmember_type=3; } } diff --git a/navit/maptool/osm_xml.c b/navit/maptool/osm_xml.c index db909a599..6cef06493 100644 --- a/navit/maptool/osm_xml.c +++ b/navit/maptool/osm_xml.c @@ -141,11 +141,11 @@ static int parse_member(char *p) { return 0; if (!osm_xml_get_attribute(p, "role", role_buffer, BUFFER_SIZE)) return 0; - if (!strcmp(type_buffer,"node")) + if (!g_strcmp0(type_buffer,"node")) type=rel_member_node; - else if (!strcmp(type_buffer,"way")) + else if (!g_strcmp0(type_buffer,"way")) type=rel_member_way; - else if (!strcmp(type_buffer,"relation")) + else if (!g_strcmp0(type_buffer,"relation")) type=rel_member_relation; else { fprintf(stderr,"Unknown type '%s'\n",type_buffer); diff --git a/navit/maptool/tile.c b/navit/maptool/tile.c index 96d32129c..f0d10332a 100644 --- a/navit/maptool/tile.c +++ b/navit/maptool/tile.c @@ -246,7 +246,7 @@ static int merge_tile(char *base, char *sub) { } static gint get_tiles_list_cmp(gconstpointer s1, gconstpointer s2) { - return strcmp((char *)s1, (char *)s2); + return g_strcmp0((char *)s1, (char *)s2); } static void get_tiles_list_func(char *key, struct tile_head *th, GList **list) { @@ -348,7 +348,7 @@ int add_aux_tile(struct zip_info *zip_info, char *name, char *filename, int size l=aux_tile_list; while (l) { at=l->data; - if (!strcmp(at->name, name)) { + if (!g_strcmp0(at->name, name)) { return -1; } l=g_list_next(l); @@ -455,7 +455,7 @@ void load_tilesdir(FILE *in) { last=&tile_head_root; while (fscanf(in,"%[^:]:%d",tile,&size) == 2) { struct tile_head *th=g_malloc(sizeof(struct tile_head)); - if (!strcmp(tile,"index")) + if (!g_strcmp0(tile,"index")) tile[0]='\0'; th->num_subtiles=0; th->total_size=size; @@ -549,7 +549,7 @@ void merge_tiles(struct tile_info *info) { do { tiles_list_sorted=get_tiles_list(); fprintf(stderr,"PROGRESS: sorting %d tiles\n", g_list_length(tiles_list_sorted)); - tiles_list_sorted=g_list_sort(tiles_list_sorted, (GCompareFunc)strcmp); + tiles_list_sorted=g_list_sort(tiles_list_sorted, (GCompareFunc)g_strcmp0); fprintf(stderr,"PROGRESS: sorting %d tiles done\n", g_list_length(tiles_list_sorted)); last=g_list_last(tiles_list_sorted); zip_size=0; diff --git a/navit/route.c b/navit/route.c index 6ddfae5cf..3b3bdd0eb 100644 --- a/navit/route.c +++ b/navit/route.c @@ -2319,7 +2319,7 @@ static void route_graph_change_traffic_distortion(struct route_graph *this, stru * @brief Adds a turn restriction item to the route graph * * @param this The route graph to add to - * @param item The item to add + * @param item The item to add, must be of `type_street_turn_restriction_no` or `type_street_turn_restriction_only` */ void route_graph_add_turn_restriction(struct route_graph *this, struct item *item) { struct route_graph_point *pnt[4]; @@ -3526,6 +3526,8 @@ static int rm_attr_get(void *priv_data, enum attr_type attr_type, struct attr *a if(mr->item.type==type_waypoint || mr->item.type == type_route_end) { if(mr->str) g_free(mr->str); + /* Build the text displayed close to the destination cursor. + * It will contain the sequence number of the waypoint (1, 2...) */ mr->str=g_strdup_printf("%d",route->reached_destinations_count+g_list_position(route->destinations,mr->dest)+1); attr->u.str=mr->str; return 1; diff --git a/navit/tools/latlon2bookmark/Makefile b/navit/tools/latlon2bookmark/Makefile index f62cc0bc4..22d3d6257 100644 --- a/navit/tools/latlon2bookmark/Makefile +++ b/navit/tools/latlon2bookmark/Makefile @@ -1,5 +1,5 @@ all: - gcc -l m -o latlon2bookmark latlon2bookmark.c + gcc -Wall -o latlon2bookmark latlon2bookmark.c -lm clean: rm -f latlon2bookmark diff --git a/navit/tools/latlon2bookmark/latlon2bookmark.c b/navit/tools/latlon2bookmark/latlon2bookmark.c index dfe1e5a7e..359fabfba 100644 --- a/navit/tools/latlon2bookmark/latlon2bookmark.c +++ b/navit/tools/latlon2bookmark/latlon2bookmark.c @@ -123,7 +123,7 @@ int main( int argc, char **argv ) { /* print the bookmark */ fprintf(stderr,"\n"); - fprintf(stdout,"mg:%s%x %s%x type=bookmark label=\"%s\"\n",lngsign,intlng,latsign,intlat,description); + fprintf(stdout,"mg:%s%ld %s%ld type=bookmark label=\"%s\"\n",lngsign,intlng,latsign,intlat,description); fprintf(stderr,"\n"); return 0; diff --git a/navit/util.c b/navit/util.c index a29b9ecb6..7e4182f27 100644 --- a/navit/util.c +++ b/navit/util.c @@ -50,6 +50,37 @@ void strtolower(char *dest, const char *src) { *dest='\0'; } +/** + * @brief Fast compute of square root for unsigned ints + * + * @param n The input number + * @return sqrt(n) + */ +unsigned int uint_sqrt(unsigned int n) { + unsigned int h, p= 0, q= 1, r= n; + + /* avoid q rollover */ + if(n >= (1<<(sizeof(n)*8-2))) { + q = 1<<(sizeof(n)*8-2); + } else { + while ( q <= n ) { + q <<= 2; + } + q >>= 2; + } + + while ( q != 0 ) { + h = p + q; + p >>= 1; + if ( r >= h ) { + p += q; + r -= h; + } + q >>= 2; + } + return p; +} + int navit_utf8_strcasecmp(const char *s1, const char *s2) { char *s1_folded,*s2_folded; int cmpres; diff --git a/navit/util.h b/navit/util.h index 140b3b850..131173ff6 100644 --- a/navit/util.h +++ b/navit/util.h @@ -28,6 +28,7 @@ void strtoupper(char *dest, const char *src); void strtolower(char *dest, const char *src); +unsigned int uint_sqrt(unsigned int n); int navit_utf8_strcasecmp(const char *s1, const char *s2); int compare_name_systematic(const char *s1, const char *s2); GList * g_hash_to_list(GHashTable *h); diff --git a/navit/xslt/android.xslt b/navit/xslt/android.xslt index 68e731be0..9ef181a88 100644 --- a/navit/xslt/android.xslt +++ b/navit/xslt/android.xslt @@ -68,7 +68,7 @@ <xsl:apply-templates/> </xsl:copy> </xsl:template> - <xsl:template match="/config/navit/layout/layer/itemgra/child::*"> + <xsl:template match="/config/navit/layout/layer/itemgra/child::*|/config/navit/layer/itemgra/child::*"> <xsl:copy> <xsl:copy-of select="@*[not(name()='text_size') and not(name()='width') and not(name()='radius') and not(name()='w') and not(name()='h') and not(name()='x') and not(name()='y') and not(name()='dash')]"/> <xsl:if test="@text_size"> |