示例#1
0
 void write_fixed_string(const std::string& command, size_t string_size)
 {
     BITCOIN_ASSERT(command.size() <= string_size);
     data_chunk raw_string(string_size);
     std::copy(command.begin(), command.end(), raw_string.begin());
     write_data(raw_string);
 }
示例#2
0
void DwarfOp<AddressType>::GetLogInfo(uint64_t start, uint64_t end,
                                      std::vector<std::string>* lines) {
  memory_->set_cur_offset(start);
  while (memory_->cur_offset() < end) {
    uint8_t cur_op;
    if (!memory_->ReadBytes(&cur_op, 1)) {
      return;
    }

    std::string raw_string(android::base::StringPrintf("Raw Data: 0x%02x", cur_op));
    std::string log_string;
    const auto* op = &kCallbackTable[cur_op];
    if (op->handle_func == nullptr) {
      log_string = "Illegal";
    } else {
      log_string = op->name;
      uint64_t start_offset = memory_->cur_offset();
      for (size_t i = 0; i < op->num_operands; i++) {
        uint64_t value;
        if (!memory_->ReadEncodedValue<AddressType>(op->operands[i], &value)) {
          return;
        }
        log_string += ' ' + std::to_string(value);
      }
      uint64_t end_offset = memory_->cur_offset();

      memory_->set_cur_offset(start_offset);
      for (size_t i = start_offset; i < end_offset; i++) {
        uint8_t byte;
        if (!memory_->ReadBytes(&byte, 1)) {
          return;
        }
        raw_string += android::base::StringPrintf(" 0x%02x", byte);
      }
      memory_->set_cur_offset(end_offset);
    }
    lines->push_back(std::move(log_string));
    lines->push_back(std::move(raw_string));
  }
}
示例#3
0
// in behaviour
RexxString *RexxString::bitAnd(RexxString *string2,
                               RexxString *pad)
{
    char        PadChar;                 /* pad character                     */
    const char *String1;                 /* string 1 pointer                  */
    const char *PadString;               /* padded string part                */
    const char *String2;                 /* string 2 pointer                  */
    sizeB_t      String1Len;              /* string 1 length                   */
    sizeB_t      String2Len;              /* string 2 length                   */
    sizeB_t      MinLength;               /* length of shorter string          */
    sizeB_t      PadLength;               /* length to pad                     */
    sizeB_t      MaxLength;               /* longest length                    */
    RexxString *Retval;                  /* return value                      */
    const char *Source;                  /* source string pointer             */
    char       *Target;                  /* target string pointer             */

                                         /* get string we will be doing bit   */
                                         /* stuff to...                       */
    string2 = optionalStringArgument(string2, OREF_NULLSTRING, ARG_ONE);
    ProtectedObject p(string2);
    String2Len = string2->getBLength();        /* get the string length             */
    String2 = string2->getStringData();       /* get the string data pointer       */
    /* get the pad character             */
    PadChar = optionalPadArgument(pad, (char)0xff, ARG_TWO);

    String1 = this->getStringData();     /* point to the first string         */
    String1Len = this->getBLength();      /* get the length                    */
    if (String1Len <= String2Len)
    {      /* string 1 shorter or equal?        */
        MinLength = String1Len;            /* string 1 is the shorter           */
        MaxLength = String2Len;            /* string 2 is the longer            */
        PadString = String2;               /* padding is done on string2        */
        Source = String1;                  /* operate from string 1             */
    }
    else
    {
        MinLength = String2Len;            /* string 2 is the shorter           */
        MaxLength = String1Len;            /* string 1 is the longer            */
        PadString = String1;               /* padding is done on string1        */
        Source = String2;                  /* operate from string 2             */
    }
    PadLength = MaxLength - MinLength;   /* get the padding length            */
                                         /* Duplicate Longer                  */
    Retval = raw_string(MaxLength);
    Target = Retval->getWritableData();  /* point to the tArget               */
    memcpy(Target, PadString, MaxLength);/* now copy in the longer one        */

    while (MinLength-- != 0)
    {                /* while shorter has data            */
                     /* and in each character             */
        *Target = *Target & *Source++;
        Target++;                          /* step the target                   */
    }

    while (PadLength-- != 0)
    {                /* while pad needed                  */
                     /* and in a pad character            */
        *Target = *Target & PadChar;
        Target++;                          /* step the target                   */
    }
    return Retval;                       /* return result string              */
}
示例#4
0
Type Type::const_string() {
	return { raw_string(), false, false, true };
}
示例#5
0
Type Type::tmp_string() {
	return { raw_string(), false, true, false };
}
示例#6
0
Type Type::string() {
	return { raw_string(), false, false, false };
}
示例#7
0
// in behaviour
RexxString *RexxString::delWord(RexxInteger *position,
                                RexxInteger *plength)
{
    char       *Current;                 /* current pointer position          */
    const char *Word;                    /* current word pointer              */
    const char *NextSite;                /* next word                         */
    sizeB_t      WordPos;                 /* needed word position              */
    size_t      Count;                   /* count of words                    */
    sizeB_t      Length;                  /* remaining length                  */
    sizeB_t      WordLength;              /* word size                         */
    sizeB_t      FrontLength;             /* front substring                   */
    RexxString *Retval;                  /* return value                      */

                                         /* convert position to binary        */
    WordPos = positionArgument(position, ARG_ONE);
    /* get num of words to delete, the   */
    /* default is "a very large number"  */
    Count = optionalLengthArgument(plength, Numerics::MAX_WHOLENUMBER, ARG_TWO);

    Length = this->getBLength();               /* get string length                 */
    if (Length == 0)                         /* null string?                      */
    {
        Retval = OREF_NULLSTRING;          /* result is null also               */
    }
    else if (Count == 0)                     /* deleting zero words?              */
    {
        Retval = this;                     /* just use this string              */
    }
    else
    {
        Word = this->getStringData();      /* point to the string               */
                                           /* get the first word                */
        WordLength = StringUtil::nextWord(&Word, &Length, &NextSite);
        while (--WordPos != 0 && WordLength != 0)
        {  /* loop until we reach tArget        */
            Word = NextSite;                 /* copy the start pointer            */
                                             /* get the next word                 */
            WordLength = StringUtil::nextWord(&Word, &Length, &NextSite);
        }
        if (WordPos != 0)                       /* run out of words first            */
        {
            Retval = this;                   /* return entire string              */
        }
        else
        {                             /* count off number of words         */
                                      /* calculate front length            */
            FrontLength = (size_t)(Word - this->getStringData());
            while (--Count != 0 && WordLength != 0)
            {  /* loop until we reach tArget        */
                Word = NextSite;               /* copy the start pointer            */
                                               /* get the next word                 */
                WordLength = StringUtil::nextWord(&Word, &Length, &NextSite);
            }
            if (Length != 0)                      /* didn't use up the string          */
            {
                StringUtil::skipBlanks(&NextSite, &Length);/* skip over trailing blanks         */
            }
                                               /* allocate return string            */
            Retval = raw_string(FrontLength + Length);
            /* point to data portion             */
            Current = Retval->getWritableData();
            if (FrontLength != 0)
            {               /* have a leading portion?           */
                            /* copy into the result              */
                memcpy(Current, this->getStringData(), FrontLength);
                Current += FrontLength;        /* step output position              */
            }
            if (Length != 0)                      /* any string left?                  */
            {
                /* copy what's left                  */
                memcpy(Current, NextSite, Length);
            }
        }
    }
    return Retval;                       /* return deleted string             */
}
示例#8
0
// in behaviour
RexxString *RexxString::space(RexxInteger *space_count,
                              RexxString  *pad)
{
    sizeC_t      Spaces;                  /* requested spacing                 */
    codepoint_t        PadChar;                 /* pad character                     */
    char       *Current;                 /* current pointer position          */
    const char *Word;                    /* current word pointer              */
    const char *NextSite;                /* next word                         */
    sizeB_t      Count;                   /* count of words                    */
    sizeB_t      WordSize;                /* size of words                     */
    sizeB_t      Length;                  /* remaining length                  */
    sizeB_t      WordLength;              /* word size                         */
    RexxString *Retval;                  /* return value                      */

                                         /* get the spacing count             */
    Spaces = optionalLengthArgument(space_count, 1, ARG_ONE);

    /* get the pad character             */
    PadChar = optionalPadArgument(pad, ' ', ARG_TWO);

    Length = this->getBLength();               /* get the string length             */
    Count = 0;                           /* no words yet                      */
    WordSize = 0;                        /* no characters either              */
    Word = this->getStringData();        /* point to the string               */
                                         /* get the first word                */
    WordLength = StringUtil::nextWord(&Word, &Length, &NextSite);

    while (WordLength != 0)
    {                 /* loop until we reach tArget        */
        Count++;                           /* count the word                    */
        WordSize += WordLength;            /* add in the word length            */
        Word = NextSite;                   /* copy the start pointer            */
                                           /* get the next word                 */
        WordLength = StringUtil::nextWord(&Word, &Length, &NextSite);
    }
    if (Count == 0)                          /* no words?                         */
    {
        Retval = OREF_NULLSTRING;          /* this is a null string             */
    }
    else
    {                               /* real words                        */
        Count--;                           /* step back one                     */
                                           /* get space for output              */
        Retval = raw_string(WordSize + Count * size_v(Spaces)); // todo m17n : Spaces is a char count
        /* point to output area              */
        Current = Retval->getWritableData();

        Length = this->getBLength();             /* recover the length                */
        Word = this->getStringData();      /* point to the string               */
                                           /* get the first word                */
        WordLength = StringUtil::nextWord(&Word, &Length, &NextSite);

        while (Count-- != 0)
        {                  /* loop for each word                */
                           /* copy the word over                */
            memcpy(Current, Word, WordLength);
            Current += WordLength;           /* step over the word                */
            if (Spaces != 0)
            {                    /* if have gaps...                   */
                                 /* fill in the pad chars             */
                memset(Current, PadChar, size_v(Spaces)); // todo m17n
                Current += size_v(Spaces);             /* step over the pad chars           */ // todo m17n
            }
            Word = NextSite;                 /* copy the start pointer            */
                                             /* get the next word                 */
            WordLength = StringUtil::nextWord(&Word, &Length, &NextSite);
        }
        /* copy the word over                */
        memcpy(Current, Word, WordLength);
    }
    return Retval;                       /* return spaced string              */
}