[Groonga-commit] groonga/groonga at 744e1ac [master] windows: avoid "stat" name conflict

Back to archive index

Hiroshi Hatake hatak****@clear*****
Sat Oct 17 22:52:03 JST 2015


util.cでgrn_boolを返している
> +  return stat(path, &status) == 0;

のに、
> +  if (grn_path_exist(conf_path) == 0) {

ともう一度真偽値比較をしているのが無駄に見えてしまったんですけど、Groongaのgrn_boolにはこのような制約があるのでしょうか?

> 2015/10/17 21:06、Kouhei Sutou <null+****@clear*****> のメール:
> 
> Author
> Kouhei Sutou <kou****@clear*****>
> Date
> 2015-10-17 21:06:55 +0900 (Sat, 17 Oct 2015)
> New Revision
> 744e1ac4ef45f79957aef079218347debd336257 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257>Message
> windows: avoid "stat" name conflict
> Modified files
> lib/db.c <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-f96f0bc0782547730f4a2616bfb33863>
> lib/grn_util.h <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-194099c8faa0eac90936109500424f10>
> lib/util.c <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-b20167ebdf308e1fa85d8efe5e670b05>
>   Modified: lib/db.c (+1 -3)
> ===================================================================
> ... <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-f96f0bc0782547730f4a2616bfb33863L32>
> 33 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-f96f0bc0782547730f4a2616bfb33863L33>
> 34 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-f96f0bc0782547730f4a2616bfb33863L34>
> 35 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-f96f0bc0782547730f4a2616bfb33863L35>
> 36 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-f96f0bc0782547730f4a2616bfb33863L36>
> 37 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-f96f0bc0782547730f4a2616bfb33863L37>
> 38 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-f96f0bc0782547730f4a2616bfb33863L38>
> 39 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-f96f0bc0782547730f4a2616bfb33863L39>
> ... <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-f96f0bc0782547730f4a2616bfb33863L202>
> 203 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-f96f0bc0782547730f4a2616bfb33863L203>
> 204 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-f96f0bc0782547730f4a2616bfb33863L204>
> 205 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-f96f0bc0782547730f4a2616bfb33863L205>
> 206 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-f96f0bc0782547730f4a2616bfb33863L206>
> 207 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-f96f0bc0782547730f4a2616bfb33863L207>
> 208 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-f96f0bc0782547730f4a2616bfb33863L208>
> 209 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-f96f0bc0782547730f4a2616bfb33863L209>
>  
> 210 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-f96f0bc0782547730f4a2616bfb33863L210>
> 211 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-f96f0bc0782547730f4a2616bfb33863L211>
> 212 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-f96f0bc0782547730f4a2616bfb33863L212>	
> ... <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-f96f0bc0782547730f4a2616bfb33863R32>
> 33 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-f96f0bc0782547730f4a2616bfb33863R33>
> 34 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-f96f0bc0782547730f4a2616bfb33863R34>
> 35 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-f96f0bc0782547730f4a2616bfb33863R35>
>  
> 36 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-f96f0bc0782547730f4a2616bfb33863R36>
> 37 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-f96f0bc0782547730f4a2616bfb33863R37>
> 38 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-f96f0bc0782547730f4a2616bfb33863R38>
> ... <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-f96f0bc0782547730f4a2616bfb33863R201>
> 202 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-f96f0bc0782547730f4a2616bfb33863R202>
> 203 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-f96f0bc0782547730f4a2616bfb33863R203>
> 204 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-f96f0bc0782547730f4a2616bfb33863R204>
>  
> 205 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-f96f0bc0782547730f4a2616bfb33863R205>
> 206 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-f96f0bc0782547730f4a2616bfb33863R206>
>  
> 207 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-f96f0bc0782547730f4a2616bfb33863R207>
> 208 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-f96f0bc0782547730f4a2616bfb33863R208>
> 209 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-f96f0bc0782547730f4a2616bfb33863R209>
> 210 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-f96f0bc0782547730f4a2616bfb33863R210>	
> @@ -33,7 +33,6 @@
>  #include "grn_report.h"
>  #include "grn_util.h"
>  #include <string.h>
> -#include <sys/stat.h>
>  
>  typedef struct {
>    grn_id id;
> @@ -203,10 +202,9 @@ static grn_bool
>  grn_db_conf_open(grn_ctx *ctx, grn_db *s, const char *path)
>  {
>    char conf_path[PATH_MAX];
> -  struct stat status;
>  
>    grn_snprintf(conf_path, PATH_MAX, PATH_MAX, GRN_DB_CONF_PATH_FORMAT, path);
> -  if (stat(conf_path, &status) == 0) {
> +  if (grn_path_exist(conf_path) == 0) {
>      s->conf = grn_hash_open(ctx, conf_path);
>      if (!s->conf) {
>        ERR(GRN_NO_MEMORY_AVAILABLE,
>   Modified: lib/grn_util.h (+1 -0)
> ===================================================================
> ... <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-194099c8faa0eac90936109500424f10L28>
> 29 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-194099c8faa0eac90936109500424f10L29>
> 30 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-194099c8faa0eac90936109500424f10L30>
> 31 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-194099c8faa0eac90936109500424f10L31>
>  
> 32 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-194099c8faa0eac90936109500424f10L32>
> 33 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-194099c8faa0eac90936109500424f10L33>
> 34 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-194099c8faa0eac90936109500424f10L34>	
> ... <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-194099c8faa0eac90936109500424f10R28>
> 29 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-194099c8faa0eac90936109500424f10R29>
> 30 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-194099c8faa0eac90936109500424f10R30>
> 31 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-194099c8faa0eac90936109500424f10R31>
> 32 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-194099c8faa0eac90936109500424f10R32>
> 33 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-194099c8faa0eac90936109500424f10R33>
> 34 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-194099c8faa0eac90936109500424f10R34>
> 35 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-194099c8faa0eac90936109500424f10R35>	
> @@ -29,6 +29,7 @@ GRN_API grn_rc grn_normalize_offset_and_limit(grn_ctx *ctx, int size, int *offse
>  GRN_API char *grn_path_separator_to_system(char *dest, char *groonga_path);
>  
>  int grn_mkstemp(char *path_template);
> +grn_bool grn_path_exist(const char *path);
>  
>  #ifdef WIN32
>  GRN_API UINT grn_windows_encoding_to_code_page(grn_encoding encoding);
>   Modified: lib/util.c (+7 -0)
> ===================================================================
> ... <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-b20167ebdf308e1fa85d8efe5e670b05L1354>
> 1355 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-b20167ebdf308e1fa85d8efe5e670b05L1355>
> 1356 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-b20167ebdf308e1fa85d8efe5e670b05L1356>
> 1357 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-b20167ebdf308e1fa85d8efe5e670b05L1357>
>  
>  
>  
>  
>  
>  
>  
> 1358 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-b20167ebdf308e1fa85d8efe5e670b05L1358>
> 1359 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-b20167ebdf308e1fa85d8efe5e670b05L1359>
> 1360 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-b20167ebdf308e1fa85d8efe5e670b05L1360>	
> ... <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-b20167ebdf308e1fa85d8efe5e670b05R1354>
> 1355 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-b20167ebdf308e1fa85d8efe5e670b05R1355>
> 1356 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-b20167ebdf308e1fa85d8efe5e670b05R1356>
> 1357 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-b20167ebdf308e1fa85d8efe5e670b05R1357>
> 1358 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-b20167ebdf308e1fa85d8efe5e670b05R1358>
> 1359 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-b20167ebdf308e1fa85d8efe5e670b05R1359>
> 1360 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-b20167ebdf308e1fa85d8efe5e670b05R1360>
> 1361 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-b20167ebdf308e1fa85d8efe5e670b05R1361>
> 1362 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-b20167ebdf308e1fa85d8efe5e670b05R1362>
> 1363 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-b20167ebdf308e1fa85d8efe5e670b05R1363>
> 1364 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-b20167ebdf308e1fa85d8efe5e670b05R1364>
> 1365 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-b20167ebdf308e1fa85d8efe5e670b05R1365>
> 1366 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-b20167ebdf308e1fa85d8efe5e670b05R1366>
> 1367 <https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257#diff-b20167ebdf308e1fa85d8efe5e670b05R1367>	
> @@ -1355,6 +1355,13 @@ grn_mkstemp(char *path_template)
>  }
>  #endif /* WIN32 */
>  
> +grn_bool
> +grn_path_exist(const char *path)
> +{
> +  struct stat status;
> +  return stat(path, &status) == 0;
> +}
> +
>  #ifdef WIN32
>  UINT
>  grn_windows_encoding_to_code_page(grn_encoding encoding)
> _______________________________________________
> Groonga-commit mailing list
> Groon****@lists*****
> http://lists.osdn.me/mailman/listinfo/groonga-commit

-------------- next part --------------
An HTML attachment was scrubbed...
Download 



More information about the Groonga-commit mailing list
Back to archive index