Changeset 167
- Timestamp:
- Mar 13, 2007, 11:58:58 AM (18 years ago)
- Location:
- Include
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
Include/api_winsock2.sbp
r150 r167 125 125 End Sub 126 126 */ 127 End /*Class*/127 End Type 'Class 128 128 129 129 Type netent -
Include/basic/function.sbp
r164 r167 11 11 12 12 13 # include <Classes/System/Math.ab>13 #require <Classes/System/Math.ab> 14 14 15 15 … … 330 330 End Function 331 331 332 Const HIBYTE(w) = (((w As Word) >> 8) and &HFF) As Byte 333 Const LOBYTE(w) = ((w As Word) and &HFF) As Byte 334 Const HIWORD(dw) = (((dw As DWord) >> 16) and &HFFFF) As Word 335 Const LOWORD(dw) = ((dw As DWord) and &HFFFF) As Word 336 337 Const MAKEWORD(a,b) = (((a As Word) and &HFF) or (((b As Word) and &HFF)<<8)) As Word 338 Const MAKELONG(a,b) = (((a As DWord) and &HFFFF) or (((b As DWord) and &HFFFF)<<16)) As Long 339 340 332 Const HIBYTE(w) = (((w As Word) >> 8) And &HFF) As Byte 333 Const LOBYTE(w) = ((w As Word) And &HFF) As Byte 334 Const HIWORD(dw) = (((dw As DWord) >> 16) And &HFFFF) As Word 335 Const LOWORD(dw) = ((dw As DWord) And &HFFFF) As Word 336 Const HIDWORD(qw) = (((qw As QWord) >> 32) And &HFFFFFFFF) As DWord 337 Const LODWORD(qw) = ((qw As QWord) And &HFFFFFFFF) As DWord 338 339 Const MAKEWORD(l, h) = (((l As Word) And &HFF) Or (((h As Word) And &HFF) << 8)) As Word 340 Const MAKEDWORD(l, h) = (((l As DWord) And &HFFFF) Or (((h As DWord) And &HFFFF) << 16)) As DWord 341 Const MAKEQWORD(l, h) = (((l As QWord) And &HFFFFFFFF) Or (((h As QWord) And &HFFFFFFFF) << 32)) As QWord 342 Const MAKELONG(l, h) = MAKEDWORD(l, h) As Long 341 343 342 344 '------------ … … 406 408 Dim _System_HexadecimalTable[&h10] = [&h30, &h31, &h32, &h33, &h34, &h35, &h36, &h37, &h38, &h39, &h41, &h42, &h43, &h44, &h45, &h46] As Byte 407 409 410 Function _System_Hex(x As DWord, zeroSuppress As Boolean) As String 411 Dim s[7] As StrChar 412 Dim i As Long 413 For i = 0 To ELM(Len (s) \ SizeOf (StrChar)) 414 s[i] = _System_HexadecimalTable[x >> 28] As StrChar 415 x <<= 4 416 Next 417 If zeroSuppress Then 418 Dim i As Long 419 For i = 0 To 6 420 If s[i] <> &h30 Then 'Asc("0") 421 Exit For 422 End If 423 Next 424 Return New String(VarPtr(s[i]) As *StrChar, Len (s) \ SizeOf (StrChar) - i) 425 Else 426 Return New String(s As *StrChar, Len (s) \ SizeOf (StrChar)) 427 End If 428 End Function 429 408 430 Function Hex$(x As DWord) As String 409 Dim i = 0 410 Hex$ = ZeroString(8) 411 While (x And &hf0000000) = 0 412 x <<= 4 413 Wend 414 While x <> 0 415 Hex$[i] = _System_HexadecimalTable[(x And &hf0000000) >> 28] As Char 416 x <<= 4 417 i++ 418 Wend 419 Hex$.ReSize(i) 431 Hex$ = _System_Hex(x, True) 420 432 End Function 421 433 422 434 Function Hex$(x As QWord) As String 423 Hex$ = Hex$((x >> 32) As DWord) + Hex$((x And &hffffffff) As DWord)435 Hex$ = _System_Hex(HIDWORD(x), True) + _System_Hex(LODWORD(x), False) 424 436 End Function 425 437 426 438 Function InStr(StartPos As Long, buf1 As String, buf2 As String) As Long 427 Dim len1 As Long, len2 As Long,i As Long, i2 As Long, i3 As Long428 429 len1=Len(buf1)430 len2=Len(buf2)439 Dim i As Long, i2 As Long, i3 As Long 440 441 Dim len1 = buf1.Length 442 Dim len2 = buf2.Length 431 443 432 444 If len2=0 Then … … 462 474 Function Left$(buf As String, length As Long) As String 463 475 Left$ = ZeroString(length) 464 memcpy(StrPtr(Left$), StrPtr(buf), SizeOf ( Char) * length)476 memcpy(StrPtr(Left$), StrPtr(buf), SizeOf (StrChar) * length) 465 477 End Function 466 478 … … 487 499 488 500 Mid$=ZeroString(ReadLength) 489 memcpy(StrPtr(Mid$), VarPtr(buf.Chars[StartPos]), SizeOf ( Char) * ReadLength)501 memcpy(StrPtr(Mid$), VarPtr(buf.Chars[StartPos]), SizeOf (StrChar) * ReadLength) 490 502 End Function 491 503 … … 515 527 If i>length Then 516 528 Right$=ZeroString(length) 517 memcpy(StrPtr(Right$), VarPtr(buf.Chars[i-length]), SizeOf ( Char) * length)529 memcpy(StrPtr(Right$), VarPtr(buf.Chars[i-length]), SizeOf (StrChar) * length) 518 530 Else 519 531 Right$=buf … … 522 534 523 535 Function Space$(length As Long) As String 524 Space$.ReSize(length, &H20 As Char)525 End Function 526 527 Dim _System_ecvt_buffer[16] As Char536 Space$.ReSize(length, &H20 As StrChar) 537 End Function 538 539 Dim _System_ecvt_buffer[16] As StrChar 528 540 Sub _ecvt_support(count As Long) 529 541 Dim i As Long … … 542 554 End If 543 555 End Sub 544 Function _ecvt(value As Double, count As Long, ByRef dec As Long, ByRef sign As Long) As *Char 545 Dim temp As *Char 556 Function _ecvt(value As Double, count As Long, ByRef dec As Long, ByRef sign As Long) As *StrChar 546 557 Dim i As Long, i2 As Long 547 558 … … 549 560 550 561 '値が0の場合 551 If value =0 Then562 If value = 0 Then 552 563 _System_FillChar(_System_ecvt_buffer, count, &H30) 553 564 _System_ecvt_buffer[count] = 0 … … 558 569 559 570 '符号の判断(同時に符号を取り除く) 560 If value <0 Then561 sign =1562 value =-value563 Else 564 sign =0571 If value < 0 Then 572 sign = 1 573 value = -value 574 Else 575 sign = 0 565 576 End If 566 577 567 578 '正規化 568 dec =1569 While value <0.999999999999999'value<1579 dec = 1 580 While value < 0.999999999999999 'value<1 570 581 value *= 10 571 582 dec-- 572 583 Wend 573 While 9.99999999999999 <=value'10<=value584 While 9.99999999999999 <= value '10<=value 574 585 value /= 10 575 586 dec++ … … 577 588 578 589 For i=0 To count-1 579 _System_ecvt_buffer[i] =Int(value) AsChar580 581 value =(value-CDbl(Int(value)))*10590 _System_ecvt_buffer[i] = Int(value) As StrChar 591 592 value = (value-CDbl(Int(value))) * 10 582 593 Next 583 _System_ecvt_buffer[i] =0594 _System_ecvt_buffer[i] = 0 584 595 585 596 i-- 586 If value >=5 Then597 If value >= 5 Then 587 598 '切り上げ処理 588 599 _ecvt_support(i) 589 600 End If 590 601 591 For i=0 To count-1602 For i=0 To ELM(count) 592 603 _System_ecvt_buffer[i] += &H30 593 604 Next 594 _System_ecvt_buffer[i] =0605 _System_ecvt_buffer[i] = 0 595 606 End Function 596 607 … … 606 617 End If 607 618 Dim dec As Long, sign As Long 608 Dim buffer[32] As Char, temp As *Char619 Dim buffer[32] As StrChar, temp As *StrChar 609 620 Dim i As Long, i2 As Long, i3 As Long 610 621 611 622 '浮動小数点を文字列に変換 612 temp =_ecvt(dbl,15,dec,sign)623 temp = _ecvt(dbl, 15, dec, sign) 613 624 614 625 i=0 … … 616 627 '符号の取り付け 617 628 If sign Then 618 buffer[i] =Asc("-")629 buffer[i] = Asc("-") 619 630 i++ 620 631 End If … … 622 633 If dec>15 Then 623 634 '指数表示(桁が大きい場合) 624 buffer[i]=temp[0] 625 i++ 626 buffer[i]=Asc(".") 627 i++ 628 memcpy(VarPtr(buffer[i]), VarPtr(temp[1]), SizeOf (Char) * 14) 635 buffer[i] = temp[0] 636 i++ 637 buffer[i] = Asc(".") 638 i++ 639 memcpy(VarPtr(buffer[i]), VarPtr(temp[1]), SizeOf (StrChar) * 14) 640 i += 14 641 buffer[i] = Asc("e") 642 i++ 643 _stprintf(VarPtr(buffer[i]), "+%03d", dec - 1) 644 645 Return MakeStr(buffer) 646 End If 647 648 If dec < -3 Then 649 '指数表示(桁が小さい場合) 650 buffer[i] = temp[0] 651 i++ 652 buffer[i] = Asc(".") 653 i++ 654 memcpy(VarPtr(buffer[i]), VarPtr(temp[1]), SizeOf (StrChar) * 14) 629 655 i+=14 630 buffer[i]=Asc("e") 631 i++ 632 _stprintf(VarPtr(buffer[i]), "+%03d", dec-1) 633 634 Return MakeStr(buffer) 635 End If 636 637 If dec<-3 Then 638 '指数表示(桁が小さい場合) 639 buffer[i]=temp[0] 640 i++ 641 buffer[i]=Asc(".") 642 i++ 643 memcpy(VarPtr(buffer[i]), VarPtr(temp[1]), SizeOf (Char) * 14) 644 i+=14 645 buffer[i]=Asc("e") 646 i++ 647 _stprintf(VarPtr(buffer[i]), "+%03d", dec-1) 656 buffer[i] = Asc("e") 657 i++ 658 _stprintf(VarPtr(buffer[i]), "+%03d", dec - 1) 648 659 649 660 Return MakeStr(buffer) … … 691 702 Return MakeStr(buffer) 692 703 End Function 704 693 705 Function Str$(value As Int64) As String 694 706 Dim temp[255] As Char … … 709 721 Dim i As Long 710 722 For i=0 To num-1 711 memcpy(VarPtr(String$[i*length]), StrPtr(buf), SizeOf ( Char) * length)723 memcpy(VarPtr(String$[i*length]), StrPtr(buf), SizeOf (StrChar) * length) 712 724 Next 713 725 End Function … … 741 753 End Function 742 754 743 Function Val(buf As * Char) As Double755 Function Val(buf As *StrChar) As Double 744 756 Dim i As Long, i2 As Long, i3 As Long, i4 As Long 745 757 Dim temporary As String 746 Dim TempPtr As * Char758 Dim TempPtr As *StrChar 747 759 Dim dbl As Double 748 760 Dim i64data As Int64 … … 766 778 If Not (0<=i3 And i3<=7) Then Exit While 767 779 768 TempPtr[i]=i3 As Char780 TempPtr[i]=i3 As StrChar 769 781 i++ 770 782 Wend … … 789 801 End If 790 802 791 TempPtr[i]=i3 As Char803 TempPtr[i]=i3 As StrChar 792 804 i++ 793 805 Wend … … 945 957 Sub _splitpath(path As PCSTR, drive As PSTR, dir As PSTR, fname As PSTR, ext As PSTR) 946 958 Dim i As Long, i2 As Long, i3 As Long, length As Long 947 Dim buffer[MAX_PATH] As Char959 Dim buffer[MAX_PATH] As SByte 948 960 949 961 '":\"をチェック … … 961 973 i2=0 962 974 Do 963 '#ifdef UNICODE964 ' If _System_IsSurrogatePair(path[i], path[i + 1]) Then965 '#else966 975 If IsDBCSLeadByte(path[i]) <> FALSE and path[i + 1] <> 0 Then 967 '#endif968 976 If dir Then 969 977 dir[i2]=path[i] … … 1055 1063 End Function 1056 1064 1065 Function _System_BSwap(x As Word) As Word 1066 Dim src = VarPtr(x) As *Byte 1067 Dim dst = VarPtr(_System_BSwap) As *SByte 1068 dst[0] = src[1] 1069 dst[1] = src[0] 1070 End Function 1071 1072 Function _System_BSwap(x As DWord) As DWord 1073 Dim src = VarPtr(x) As *Byte 1074 Dim dst = VarPtr(_System_BSwap) As *SByte 1075 dst[0] = src[3] 1076 dst[1] = src[2] 1077 dst[2] = src[1] 1078 dst[3] = src[0] 1079 End Function 1080 1081 Function _System_BSwap(x As QWord) As QWord 1082 Dim src = VarPtr(x) As *Byte 1083 Dim dst = VarPtr(_System_BSwap) As *SByte 1084 dst[0] = src[7] 1085 dst[1] = src[6] 1086 dst[2] = src[5] 1087 dst[3] = src[4] 1088 dst[4] = src[3] 1089 dst[5] = src[2] 1090 dst[6] = src[1] 1091 dst[7] = src[0] 1092 End Function 1093 1057 1094 '-------- 1058 1095 ' 文字列関数その2 -
Include/system/string.sbp
r149 r167 5 5 #define _INC_BASIC_STRING 6 6 7 Function StrPtr(buf As * Char) As *Char7 Function StrPtr(buf As *StrChar) As *StrChar 8 8 StrPtr = buf 9 9 End Function … … 15 15 End Function 16 16 17 Function MakeStr(pBuf As PSTR) As String 18 Dim temp As String(pBuf) 19 Return temp 20 End Function 21 22 Function MakeStr(pBuf As PWSTR) As String 23 Dim temp As String(pBuf) 24 Return temp 17 Function MakeStr(psz As PSTR) As String 18 Return New String(psz) 19 End Function 20 21 Function MakeStr(psz As PWSTR) As String 22 Return New String(psz) 25 23 End Function 26 24
Note:
See TracChangeset
for help on using the changeset viewer.