Displaying 4 results from an estimated 4 matches for "digits_only".
2009 Mar 18
2
Profiling question: string formatting extremely slow
...rds.
Is there a way to find out which of the function used below is the
bottleneck, as.integer, is.na, sub, paste, nchar, toupper? Is there a
profiler for R and if yes where could I find some documentation on how to
use it?
The code:
# String contains digits only (can be converted to an integer)
digits_only <- function(x) { suppressWarnings(!is.na(as.integer(x))) }
# Remove blanks at both ends of a string
trim <- function (x) {
sub("^\\s+((.*\\S)\\s+)?$", "\\2", x)
}
# P/N formatting
pn_formatting <- function(pn_in) {
pn_out = trim(pn_in)
if (digits_only(pn_out))...
2006 Feb 03
9
validating phone numbers
Anyone got a good validation for validating a phone number? I just
want to make sure that whatever the user enters is somewhat sensical,
and i''d like to be fairly liberal about what kind of a format it''s in.
Joe
2019 Nov 05
0
[klibc:master] losetup: Fix char signedness mismatches with <linux/loop.h>
...t_loop(const char *device, const char *file, unsigned long long offset,
memset(&loopinfo64, 0, sizeof(loopinfo64));
- xstrncpy(loopinfo64.lo_file_name, file, LO_NAME_SIZE);
+ xstrncpy((char *)loopinfo64.lo_file_name, file, LO_NAME_SIZE);
if (encryption && *encryption) {
if (digits_only(encryption)) {
loopinfo64.lo_encrypt_type = atoi(encryption);
} else {
loopinfo64.lo_encrypt_type = LO_CRYPT_CRYPTOAPI;
- snprintf(loopinfo64.lo_crypt_name, LO_NAME_SIZE,
+ snprintf((char *)loopinfo64.lo_crypt_name, LO_NAME_SIZE,
"%s", encryption);
}
}
@@ -284,7...
2010 Mar 14
0
[patches] klibc review unsorted patch queue
...ng passphrase");
+ pass = tmppass; /* the old buffer hasn't changed */
+ break;
+ }
+ }
+ if (read(pfd, pass+i, 1) != 1 ||
+ pass[i] == '\n' || pass[i] == 0)
+ break;
+ }
+
+ if (pass == NULL)
+ return "";
+
+ pass[i] = 0;
+ return pass;
+}
+
+static int digits_only(const char *s)
+{
+ while (*s)
+ if (!isdigit(*s++))
+ return 0;
+ return 1;
+}
+
+int set_loop(const char *device, const char *file, unsigned long long offset,
+ const char *encryption, int pfd, int *loopro) {
+ struct loop_info64 loopinfo64;
+ int fd, ffd, mode, i;
+ char *pass;
+
+ mode = (*...