Skip to content

Commit 3c1a7c6

Browse files
committed
Add Suggested changes
1 parent a2fa23f commit 3c1a7c6

File tree

5 files changed

+11
-26
lines changed

5 files changed

+11
-26
lines changed

po/es.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1282,7 +1282,7 @@ msgstr "Tipo 'measure.vars' desconocido %s en el índice %d de la lista"
12821282

12831283
#: fmelt.c:187
12841284
msgid "One or more values in 'measure.vars' is invalid; please fix by removing: %s"
1285-
msgstr "Uno o más valores en 'measure.vars' no son válidos; por favor corrige eliminando: %s"
1285+
msgstr "Uno o más valores en 'measure.vars' no son válidos."
12861286

12871287
#: fmelt.c:189
12881288
msgid "One or more values in 'id.vars' is invalid."

po/fr.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1302,7 +1302,7 @@ msgstr "Type inconnu de 'measure.vars' %s à l'indice %d de la liste"
13021302

13031303
#: fmelt.c:187
13041304
msgid "One or more values in 'measure.vars' is invalid; please fix by removing: %s"
1305-
msgstr "Une ou plusieurs valeurs de 'measure.vars' ne sont pas valides; veuillez corriger en supprimant : %s"
1305+
msgstr "Une ou plusieurs valeurs de 'measure.vars' ne sont pas valides."
13061306

13071307
#: fmelt.c:189
13081308
msgid "One or more values in 'id.vars' is invalid."

po/pt_BR.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1282,7 +1282,7 @@ msgstr "'measure.vars'com tipo desconhecido %s no índice %d da lista"
12821282

12831283
#: fmelt.c:187
12841284
msgid "One or more values in 'measure.vars' is invalid; please fix by removing: %s"
1285-
msgstr "Um ou mais valores em 'measure.vars' são inválidos; por favor, corrija removendo: %s"
1285+
msgstr "Um ou mais valores em 'measure.vars' são inválidos."
12861286

12871287
#: fmelt.c:189
12881288
msgid "One or more values in 'id.vars' is invalid."

po/zh_CN.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1155,7 +1155,7 @@ msgstr "未知'measure.vars'类型 %s,位于列表中 %d"
11551155

11561156
#: fmelt.c:187
11571157
msgid "One or more values in 'measure.vars' is invalid; please fix by removing: %s"
1158-
msgstr "'measure.vars'里,一或多个数值无效;请通过删除以下数值来修复:%s"
1158+
msgstr "'measure.vars'里,一或多个数值无效"
11591159

11601160
#: fmelt.c:189
11611161
msgid "One or more values in 'id.vars' is invalid."

src/fmelt.c

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include "data.table.h"
22
#include <Rdefines.h>
33

4-
54
// #include <signal.h> // the debugging machinery + breakpoint aidee
65
// raise(SIGINT);
76

@@ -178,72 +177,58 @@ bool is_default_measure(SEXP vec) {
178177

179178
// maybe unlist, then unique, then set_diff.
180179
SEXP uniq_diff(SEXP int_or_list, int ncol, bool is_measure) {
181-
// Protect input list/vector, unlisting if necessary
182180
SEXP int_vec = PROTECT(isNewList(int_or_list) ? unlist_(int_or_list) : int_or_list);
183181

184-
// Check for duplicated elements in the input vector
185182
SEXP is_duplicated = PROTECT(duplicated(int_vec, FALSE));
186183

187184
int n_unique_cols = 0;
188-
189-
// Allocate a vector to store invalid column indices (initially max size is length of int_vec)
185+
190186
SEXP invalid_columns = PROTECT(allocVector(INTSXP, length(int_vec)));
191187
int* invalid_col_ptr = INTEGER(invalid_columns);
192188
int invalid_count = 0;
193189

194-
// Iterate through the column numbers to identify invalid and unique columns
195190
for (int i = 0; i < length(int_vec); ++i) {
196191
int col_number = INTEGER(int_vec)[i];
197192

198-
// Check if the column number is within valid range
199193
bool good_number = 0 < col_number && col_number <= ncol;
200194

201-
// Special check for 'measure' case (NA_INTEGER handling)
202195
if (is_measure) good_number |= (col_number == NA_INTEGER);
203196

204-
// Collect invalid columns if not valid or out of range
205197
if (!good_number || col_number == 0) {
206198
invalid_col_ptr[invalid_count++] = col_number;
207199
} else if (!LOGICAL(is_duplicated)[i]) {
208200
n_unique_cols++;
209201
}
210202
}
211203

212-
// If invalid columns are found, construct the error message
213204
if (invalid_count > 0) {
214-
// Buffer for concatenated invalid column messages
215-
char buffer[4096] = ""; // Large enough to store the concatenated string
205+
char buffer[4096] = "";
216206
for (int i = 0; i < invalid_count; ++i) {
217207
char temp[32];
218-
snprintf(temp, 32, "[%d]", invalid_col_ptr[i]); // Format the column number
208+
snprintf(temp, 32, "[%d]", invalid_col_ptr[i]);
219209

220210
if (i > 0) {
221-
strncat(buffer, ", ", sizeof(buffer) - strlen(buffer) - 1); // Add separator
211+
strncat(buffer, ", ", sizeof(buffer) - strlen(buffer) - 1);
222212
}
223-
strncat(buffer, temp, sizeof(buffer) - strlen(buffer) - 1); // Append to the buffer
213+
strncat(buffer, temp, sizeof(buffer) - strlen(buffer) - 1);
224214
}
225215

226-
// Throw the error with the concatenated message
227216
error(_("One or more values in '%s' are invalid; please fix by removing: %s"),
228217
is_measure ? "measure.vars" : "id.vars", buffer);
229218
}
230-
231-
// Proceed with collecting unique columns
219+
232220
SEXP unique_col_numbers = PROTECT(allocVector(INTSXP, n_unique_cols));
233221
int unique_i = 0;
234222

235-
// Populate the unique column numbers into the new vector
236223
for (int i = 0; i < length(is_duplicated); ++i) {
237224
if (!LOGICAL(is_duplicated)[i]) {
238225
INTEGER(unique_col_numbers)[unique_i++] = INTEGER(int_vec)[i];
239226
}
240227
}
241228

242-
// Apply set difference to get final unique column indices
243229
SEXP out = set_diff(unique_col_numbers, ncol);
244230

245-
// Unprotect all allocated objects
246-
UNPROTECT(4); // Unprotect input, duplication check, invalid columns, and unique columns
231+
UNPROTECT(4);
247232

248233
return out;
249234
}

0 commit comments

Comments
 (0)