blob: 60b8d529f9bc0b44934f62a7b6a114c85af090df (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
void
do_vecset(mstr,TARG)
STR *mstr;
STR *TARG;
{
struct lstring *lstr = (struct lstring*)TARG;
register int offset;
register int size;
register unsigned char *s = (unsigned char*)mstr->str_ptr;
register unsigned long lval = U_L(str_gnum(TARG));
int mask;
mstr->str_rare = 0;
TARG->str_magic = Nullstr;
offset = lstr->lstr_offset;
size = lstr->lstr_len;
if (size < 8) {
mask = (1 << size) - 1;
size = offset & 7;
lval &= mask;
offset >>= 3;
s[offset] &= ~(mask << size);
s[offset] |= lval << size;
}
else {
if (size == 8)
s[offset] = lval & 255;
else if (size == 16) {
s[offset] = (lval >> 8) & 255;
s[offset+1] = lval & 255;
}
else if (size == 32) {
s[offset] = (lval >> 24) & 255;
s[offset+1] = (lval >> 16) & 255;
s[offset+2] = (lval >> 8) & 255;
s[offset+3] = lval & 255;
}
}
}
|