linux-scalability-benchmarks / libowfat / scan / scan_uint.c

The default branch has multiple heads

#include "scan.h"

/* this is cut and paste from scan_ulong instead of calling scan_ulong
 * because this way scan_uint can abort scanning when the number would
 * not fit into an unsigned int (as opposed to not fitting in an
 * unsigned long) */

size_t scan_uint(const char* src,unsigned int* dest) {
  if (sizeof(unsigned int) == sizeof(unsigned long)) {
    /* a good optimizing compiler should remove the else clause when not
     * needed */
    return scan_ulong(src,(unsigned long*)dest);
  } else {
    register const char *tmp=src;
    register unsigned int l=0;
    register unsigned char c;
    while ((c=*tmp-'0')<10) {
      unsigned int n;
      /* division is very slow on most architectures */
      n=l<<3; if ((n>>3)!=l) break;
      if (n+(l<<1) < n) break;
      if (n+c < n) break;
    if (tmp-src) *dest=l;
    return tmp-src;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.