From 5319e167cd0e2bea9da758a68824401a26fd2b3f Mon Sep 17 00:00:00 2001 From: Karl Lehenbauer Date: Thu, 13 Feb 2014 19:50:43 +0000 Subject: [PATCH] Make "::mongo::bson create #auto" and "$mongo cursor #auto..." work properly. BUGZID: --- generic/bson.c | 4 ++-- generic/cursor.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/generic/bson.c b/generic/bson.c index 9a7e74d..48f38e0 100644 --- a/generic/bson.c +++ b/generic/bson.c @@ -745,9 +745,9 @@ mongotcl_create_bson_command (Tcl_Interp *interp, char *commandName, CONST bson static unsigned long nextAutoCounter = 0; int baseNameLength; - baseNameLength = strlen(commandName) + snprintf (NULL, 0, "%lu", nextAutoCounter) + 1; + baseNameLength = strlen("bson") + snprintf (NULL, 0, "%lu", nextAutoCounter) + 1; commandName = ckalloc (baseNameLength); - snprintf (commandName, baseNameLength, "%s%lu", commandName, nextAutoCounter++); + snprintf (commandName, baseNameLength, "bson%lu", nextAutoCounter++); autoGeneratedName = 1; } diff --git a/generic/cursor.c b/generic/cursor.c index 3bd705b..db57946 100644 --- a/generic/cursor.c +++ b/generic/cursor.c @@ -396,9 +396,9 @@ mongotcl_createCursorObjCmd(Tcl_Interp *interp, mongo *conn, char *commandName, static unsigned long nextAutoCounter = 0; int baseNameLength; - baseNameLength = strlen(commandName) + snprintf (NULL, 0, "%lu", nextAutoCounter) + 1; + baseNameLength = strlen("cursor") + snprintf (NULL, 0, "%lu", nextAutoCounter) + 1; commandName = ckalloc (baseNameLength); - snprintf (commandName, baseNameLength, "%s%lu", commandName, nextAutoCounter++); + snprintf (commandName, baseNameLength, "cursor%lu", nextAutoCounter++); autoGeneratedName = 1; }