Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1202 lines
28 KiB

  1. PAGE 60,132
  2. TITLE Edlcmd2 - PART2 procedures called from EDLIN
  3. ;/*
  4. ; * Microsoft Confidential
  5. ; * Copyright (C) Microsoft Corporation 1991
  6. ; * All Rights Reserved.
  7. ; */
  8. ;======================= START OF SPECIFICATIONS =========================
  9. ;
  10. ; MODULE NAME: EDLCMD2.SAL
  11. ;
  12. ; DESCRIPTIVE NAME: EDLIN ROUTINES
  13. ;
  14. ; FUNCTION: THIS MODULE PROVIDES ROUTINES NEEDED FOR EDLIN'S EXECUTION.
  15. ;
  16. ; ENTRY POINT: ANY CALLED ROUTINE
  17. ;
  18. ; EXIT NORMAL: NA
  19. ;
  20. ; EXIT ERROR : NA
  21. ;
  22. ; INTERNAL REFERENCES:
  23. ;
  24. ; EXTERNAL REFERENCES:
  25. ;
  26. ; ROUTINE: EDLCMD1 - ROUTINES MAY BE CALLED FROM EDLCMD1
  27. ; EDLMES - ROUTINES MAY BE CALLED FROM EDLMES
  28. ;
  29. ; NOTES: THIS MODULE IS TO BE PREPPED BY SALUT WITH THE "PR" OPTIONS.
  30. ; LINK EDLIN+EDLCMD1+EDLCMD2+EDLMES+EDLPARSE
  31. ;
  32. ;
  33. ; REVISION HISTORY:
  34. ;
  35. ; AN000 VERSION DOS 4.00 - REVISIONS MADE RELATE TO THE FOLLOWING:
  36. ;
  37. ; - IMPLEMENT SYSPARSE
  38. ; - IMPLEMENT MESSAGE RETRIEVER
  39. ; - IMPLEMENT DBCS ENABLING
  40. ; - ENHANCED VIDEO SUPPORT
  41. ; - EXTENDED OPENS
  42. ; - SCROLLING ERROR
  43. ;
  44. ; COPYRIGHT: "MS DOS EDLIN UTILITY"
  45. ; "VERSION 4.00 (C) COPYRIGHT 1988 Microsoft"
  46. ;
  47. ;======================= END OF SPECIFICATIONS ===========================
  48. include edlequ.asm
  49. include syscall.inc
  50. CODE SEGMENT PUBLIC
  51. CODE ENDS
  52. CONST SEGMENT PUBLIC WORD
  53. CONST ENDS
  54. cstack segment stack
  55. cstack ends
  56. DATA SEGMENT PUBLIC WORD
  57. DATA ENDS
  58. DG GROUP CODE,CONST,cstack,DATA
  59. CONST SEGMENT PUBLIC WORD
  60. extrn msg_crlf:abs,msg_lf:abs,qmes_ptr:byte,ask_ptr:byte
  61. extrn bak:byte,$$$file:byte,delflg:byte,loadmod:byte,txt1:byte
  62. extrn txt2:byte,memful_ptr:word
  63. extrn Del_Bak_Ptr:byte ;an000;dms;
  64. extrn cont_ptr:byte ;an000;dms:6/10/87
  65. CONST ENDS
  66. DATA SEGMENT PUBLIC WORD
  67. extrn ParamCt:WORD
  68. extrn current:word,pointer:word,start:word,endtxt:word
  69. extrn wrt_handle:word,editbuf:byte,ext_ptr:word,qflg:byte
  70. extrn temp_path:byte,line_num:word,line_flag:byte
  71. extrn line_num_buf_ptr:byte,arg_buf:byte,arg_buf_ptr:word
  72. extrn olddat:byte,oldlen:word,newlen:word,param1:word,param2:word
  73. extrn srchflg:byte,srchmod:byte,comline:word,lstfnd:word,numpos:word
  74. extrn lstnum:word,last_mem:word,srchcnt:word,amnt_req:word
  75. extrn lc_adj:byte ;an000;dms:6/10/87
  76. extrn continue:byte ;an000;dms:6/10/87
  77. extrn pg_count:byte ;an000;dms:6/10/87
  78. extrn Disp_Len:byte ;an000;dms;
  79. extrn Disp_Width:byte ;an000;dms;
  80. extrn lc_flag:byte ;an000;dms:6/10/87
  81. ifdef DBCS
  82. extrn lbtbl:dword
  83. endif
  84. DATA ENDS
  85. CODE SEGMENT PUBLIC
  86. ASSUME CS:DG,DS:DG,SS:CStack,ES:DG
  87. public findlin,shownum,loadbuf,crlf,lf,abortcom,unquote
  88. public kill_bl,make_caps,display,dispone,make_cntrl
  89. public query,quit,scanln,delbak,scaneof,memerr
  90. public fndfirst,fndnext,replace
  91. ifdef DBCS
  92. public testkanj
  93. endif
  94. extrn std_printf:near,command:near,chkrange:near,ComErr:NEAR
  95. extrn Xerror:near
  96. extrn display_message:near
  97. FINDLIN:
  98. ; Inputs
  99. ; BX = Line number to be located in buffer (0 means last line+1)
  100. ; Outputs:
  101. ; DX = Actual line found
  102. ; DI = Pointer to start of line DX
  103. ; Zero set if BX = DX (if specified line found)
  104. ; AL,CX destroyed. No other registers affected.
  105. MOV DX,[CURRENT]
  106. MOV DI,[POINTER]
  107. CMP BX,DX ; fast find. Current = requested
  108. retz
  109. JA FINDIT ; start scanning at current?
  110. OR BX,BX ; special case of EOF?
  111. JZ FINDIT ; yes
  112. MOV DX,1 ; set up for scan at beginning
  113. MOV DI,OFFSET DG:START
  114. CMP BX,DX ; at beginning?
  115. retz
  116. FINDIT:
  117. MOV CX,[ENDTXT] ; count of bytes in buffer
  118. SUB CX,DI ; for scan
  119. SCANLN:
  120. MOV AL,10 ; LF is what we look for.
  121. OR AL,AL ; Clear zero flag for JCXZ
  122. FINLIN:
  123. JCXZ RET4 ; at end? Yes, no skip.
  124. REPNE SCASB ; find EOL
  125. INC DX ; increment count
  126. CMP BX,DX ; find correct line?
  127. JNZ FINLIN ; no, try again.
  128. RET4: return
  129. ; Inputs:
  130. ; BX = Line number to be displayed
  131. ; Function:
  132. ; Displays line number on terminal in 8-character
  133. ; format, suppressing leading zeros.
  134. ; AX, CX, DX destroyed. No other registers affected.
  135. SHOWNUM:
  136. mov dx,offset dg:line_num_buf_ptr
  137. mov line_num,bx
  138. MOV line_flag,"*"
  139. CMP BX,[CURRENT]
  140. JZ STARLIN
  141. MOV line_flag," "
  142. STARLIN:
  143. call std_printf
  144. ret5: return
  145. DISPONE:
  146. MOV DI,1
  147. DISPLAY:
  148. ; Inputs:
  149. ; BX = Line number
  150. ; SI = Pointer to text buffer
  151. ; DI = No. of lines
  152. ; Function:
  153. ; Ouputs specified no. of line to terminal, each
  154. ; with leading line number.
  155. ; Outputs:
  156. ; BX = Last line output.
  157. ; All registers destroyed.
  158. MOV CX,[ENDTXT]
  159. SUB CX,SI
  160. retz ; no lines to display
  161. ;=========================================================================
  162. ; Initialize screen size and line counts for use by display.
  163. ;
  164. ; Date : 6/10/87
  165. ;=========================================================================
  166. push ax ;an000;save affected regs
  167. mov al,dg:disp_len ;an000;length of video display
  168. mov pg_count,al ;an000;init. screen size ctr.
  169. pop ax ;an000;restore affected regs
  170. ;=========================================================================
  171. mov dx,di ;number of lines to print
  172. ;
  173. ; CX is the number of bytes in the buffer
  174. ; dx is the number of lines to be output
  175. ;
  176. DISPLN:
  177. SaveReg <CX,DX>
  178. CALL SHOWNUM
  179. RestoreReg <DX,CX>
  180. mov di,offset dg:arg_buf
  181. ;
  182. ; Copy chars until CR/LF or end of line hit
  183. ;
  184. OUTLN:
  185. LODSB
  186. CMP DI,254+offset dg:arg_buf ; are we at end of buffer?
  187. JAE StoreDone ; Yes, do NOT store
  188. CMP AL," "
  189. JAE SEND
  190. CMP AL,10
  191. JZ SEND
  192. CMP AL,13
  193. JZ SEND
  194. CMP AL,9
  195. JZ SEND
  196. MOV AH,"^"
  197. OR AL,40h
  198. XCHG AL,AH
  199. STOSW
  200. JMP short StoreDone
  201. SEND:
  202. stosb
  203. StoreDone:
  204. CMP AL,10 ; perform copy until LF is seen
  205. LOOPNZ OUTLN
  206. ;
  207. ; Make sure buffer ends with CRLF
  208. ;
  209. cmp byte ptr [di-1],10
  210. jz Terminate
  211. ;
  212. ; No LF seen. See if CR
  213. ;
  214. cmp byte ptr [di-1],CR
  215. jz StoreLF
  216. mov al,CR
  217. stosb
  218. StoreLF:
  219. mov al,10
  220. stosb
  221. Terminate:
  222. mov byte ptr [di],0
  223. call EDLIN_DISP_COUNT ;an000;determine lines printed
  224. ; DMS:6/10/87
  225. push dx
  226. mov dx,offset dg:arg_buf_ptr
  227. call std_printf
  228. pop dx
  229. JCXZ ret7
  230. INC BX
  231. call EDLIN_PG_COUNT ;an000;adjust screen line count
  232. ; DMS:6/10/87
  233. cmp lc_flag,false ;an000;continue DISPLAY?
  234. ; DMS:6/10/87
  235. JNZ DISPLN
  236. DEC BX
  237. ret7: return
  238. FNDFIRST:
  239. MOV DI,1+OFFSET DG:TXT1
  240. mov byte ptr[olddat],1 ;replace with old value if none new
  241. CALL GETTEXT
  242. OR AL,AL ;Reset zero flag in case CX is zero
  243. JCXZ RET7
  244. cmp al,1ah ;terminated with a ^Z ?
  245. jne sj8
  246. mov byte ptr[olddat],0 ;do not replace with old value
  247. sj8:
  248. MOV [OLDLEN],CX
  249. XOR CX,CX
  250. CMP AL,0DH
  251. JZ SETBUF
  252. CMP BYTE PTR [SRCHFLG],0
  253. JZ NXTBUF
  254. SETBUF:
  255. DEC SI
  256. NXTBUF:
  257. MOV [COMLINE],SI
  258. MOV DI,1+OFFSET DG:TXT2
  259. CALL GETTEXT
  260. CMP BYTE PTR [SRCHFLG],0
  261. JNZ NOTREPL
  262. CMP AL,0DH
  263. JNZ HAVCHR
  264. DEC SI
  265. HAVCHR:
  266. MOV [COMLINE],SI
  267. NOTREPL:
  268. MOV [NEWLEN],CX
  269. MOV BX,[PARAM1]
  270. OR BX,BX
  271. JNZ CALLER
  272. cmp byte ptr[srchmod],0
  273. jne sj9
  274. mov bx,1 ;start from line number 1
  275. jmp short sj9a
  276. sj9:
  277. MOV BX,[CURRENT]
  278. INC BX ;Default search and replace to current+1
  279. sj9a:
  280. CALL CHKRANGE
  281. CALLER:
  282. CALL FINDLIN
  283. MOV [LSTFND],DI
  284. MOV [NUMPOS],DI
  285. MOV [LSTNUM],DX
  286. MOV BX,[PARAM2]
  287. CMP BX,1
  288. SBB BX,-1 ;Decrement everything except zero
  289. CALL FINDLIN
  290. MOV CX,DI
  291. SUB CX,[LSTFND]
  292. OR AL,-1
  293. JCXZ aret
  294. CMP CX,[OLDLEN]
  295. jae sj10
  296. aret: return
  297. sj10:
  298. MOV [SRCHCNT],CX
  299. FNDNEXT:
  300. ; Inputs:
  301. ; [TXT1+1] has string to search for
  302. ; [OLDLEN] has length of the string
  303. ; [LSTFND] has starting position of search in text buffer
  304. ; [LSTNUM] has line number which has [LSTFND]
  305. ; [SRCHCNT] has length to be searched
  306. ; [NUMPOS] has beginning of line which has [LSTFND]
  307. ; Outputs:
  308. ; Zero flag set if match found
  309. ; [LSTFND],[LSTNUM],[SRCHCNT] updated for continuing the search
  310. ; [NUMPOS] has beginning of line in which match was made
  311. MOV AL,[TXT1+1]
  312. MOV CX,[SRCHCNT]
  313. MOV DI,[LSTFND]
  314. SCAN:
  315. OR DI,DI ;Clear zero flag in case CX=0
  316. REPNE SCASB ;look for first byte of string
  317. retnz ;return if you don't find
  318. ifdef DBCS
  319. call kanji_check ;see if the found byte is on a character boundary
  320. jnz scan
  321. endif
  322. MOV DX,CX
  323. MOV BX,DI ;Save search position
  324. MOV CX,[OLDLEN]
  325. DEC CX
  326. MOV SI,2 + OFFSET DG:TXT1
  327. CMP AL,AL ;Set zero flag in case CX=0
  328. REPE CMPSB
  329. MOV CX,DX
  330. MOV DI,BX
  331. JNZ SCAN
  332. MOV [SRCHCNT],CX
  333. MOV CX,DI
  334. MOV [LSTFND],DI
  335. MOV DI,[NUMPOS]
  336. SUB CX,DI
  337. MOV AL,10
  338. MOV DX,[LSTNUM]
  339. ;Determine line number of match
  340. GETLIN:
  341. INC DX
  342. MOV BX,DI
  343. REPNE SCASB
  344. JZ GETLIN
  345. DEC DX
  346. MOV [LSTNUM],DX
  347. MOV [NUMPOS],BX
  348. XOR AL,AL
  349. return
  350. ifdef DBCS
  351. ;Kanji_check idea is to scan backwards to the first
  352. ; character which can't be a kanji or part of one
  353. ; (.lt. DB_SP_LO) then scan forward to see if the
  354. ; current byte is on character boundary
  355. ;
  356. ;Output ZR <==> we're on a character boundary
  357. ; NZ <==> we're not on character boundary i.e. No Match
  358. kanji_check:
  359. push ax ;save search character
  360. push di
  361. dec di ;point to the character we found
  362. mov si,di ;start searching bakwards from there
  363. std
  364. srch_loop:
  365. lodsb
  366. cmp al,DB_SP_LO
  367. jae srch_loop
  368. inc si ;point to first non-kanji
  369. cld ;forward search
  370. kan_loop:
  371. cmp si,di ;are we at current byte?
  372. jae passed_char ;if we are, or are passed it, exit
  373. call next_char ;otherwise advance si to next char
  374. jmp short kan_loop ;and loop
  375. passed_char:
  376. pop di
  377. pop ax
  378. ret
  379. ;Next_char si points to a character boundary
  380. ; advance si to point to the beginning of the next char
  381. ;
  382. ;
  383. next_char:
  384. push ax
  385. lodsb
  386. call testkanj
  387. jz not_kanj
  388. inc si
  389. not_kanj:
  390. pop ax
  391. ret
  392. ;--------------------------------------------------------------------;
  393. ; TESTKANJ ~ FIND OUT IS THE BYTE IS A KANJI PREFIX ;
  394. ; ;
  395. ; entry: AL byte to test ;
  396. ; ;
  397. ; exit: NZ if lead byte ortherwise ZR ;
  398. ; ;
  399. ; modifies: AX ;
  400. ; ;
  401. ;--------------------------------------------------------------------;
  402. testkanj:
  403. push ax
  404. xchg ah,al ;put byte in ah
  405. push ds
  406. push si
  407. lds si,cs:[lbtbl] ;get pointer to lead byte table
  408. ktlop:
  409. lodsb ;direction flag should be OK
  410. or al,al ;are we at the end of table?
  411. jz notlead ;brif so
  412. cmp al,ah ;is START RANGE > CHARACTER?
  413. ja notlead ;brif so, not a lead character (carry clear)
  414. lodsb ;get second range byte
  415. cmp ah,al ;is CHARACTER > END RANGE
  416. ja ktlop ;brif so, not a lead character (check next range)
  417. or al,al ;make NZ
  418. notl_exit:
  419. pop si
  420. pop ds
  421. pop ax
  422. ret
  423. notlead:
  424. cmp al,al
  425. jmp notl_exit
  426. endif
  427. GETTEXT:
  428. ; Inputs:
  429. ; SI points into command line buffer
  430. ; DI points to result buffer
  431. ; Function:
  432. ; Moves [SI] to [DI] until ctrl-Z (1AH) or
  433. ; RETURN (0DH) is found. Termination char not moved.
  434. ; Outputs:
  435. ; AL = Termination character
  436. ; CX = No of characters moved.
  437. ; SI points one past termination character
  438. ; DI points to next free location
  439. XOR CX,CX
  440. GETIT:
  441. LODSB
  442. ;-----------------------------------------------------------------------
  443. cmp al,quote_char ;a quote character?
  444. jne sj101 ;no, skip....
  445. lodsb ;yes, get quoted character
  446. call make_cntrl
  447. jmp short sj102
  448. ;-----------------------------------------------------------------------
  449. sj101:
  450. CMP AL,1AH
  451. JZ DEFCHK
  452. sj102:
  453. CMP AL,0DH
  454. JZ DEFCHK
  455. STOSB
  456. INC CX
  457. JMP SHORT GETIT
  458. DEFCHK:
  459. OR CX,CX
  460. JZ OLDTXT
  461. PUSH DI
  462. SUB DI,CX
  463. MOV BYTE PTR [DI-1],cl
  464. POP DI
  465. return
  466. OLDTXT:
  467. cmp byte ptr[olddat],1 ;replace with old text?
  468. je sj11 ;yes...
  469. mov byte ptr[di-1],cl ;zero text buffer char count
  470. return
  471. sj11:
  472. MOV CL,BYTE PTR [DI-1]
  473. ADD DI,CX
  474. return
  475. REPLACE:
  476. ; Inputs:
  477. ; CX = Length of new text
  478. ; DX = Length of original text
  479. ; SI = Pointer to new text
  480. ; DI = Pointer to old text in buffer
  481. ; Function:
  482. ; New text replaces old text in buffer and buffer
  483. ; size is adjusted. CX or DX may be zero.
  484. ; CX, SI, DI all destroyed. No other registers affected.
  485. CMP CX,DX
  486. JZ COPYIN
  487. PUSH SI
  488. PUSH DI
  489. PUSH CX
  490. MOV SI,DI
  491. ADD SI,DX
  492. ADD DI,CX
  493. MOV AX,[ENDTXT]
  494. SUB AX,DX
  495. ADD AX,CX
  496. CMP AX,[LAST_MEM]
  497. JAE MEMERR
  498. XCHG AX,[ENDTXT]
  499. MOV CX,AX
  500. SUB CX,SI
  501. CMP SI,DI
  502. JA DOMOV
  503. ADD SI,CX
  504. ADD DI,CX
  505. STD
  506. DOMOV:
  507. INC CX
  508. REP MOVSB
  509. CLD
  510. POP CX
  511. POP DI
  512. POP SI
  513. COPYIN:
  514. REP MOVSB
  515. return
  516. MEMERR:
  517. MOV DX,OFFSET DG:MEMFUL_ptr
  518. call std_printf
  519. JMP COMMAND
  520. LOADBUF:
  521. MOV DI,2 + OFFSET DG:EDITBUF
  522. MOV CX,255
  523. MOV DX,-1
  524. LOADLP:
  525. LODSB
  526. STOSB
  527. INC DX
  528. CMP AL,13
  529. LOOPNZ LOADLP
  530. MOV [EDITBUF+1],DL
  531. retz
  532. TRUNCLP:
  533. LODSB
  534. INC DX
  535. CMP AL,13
  536. JNZ TRUNCLP
  537. DEC DI
  538. STOSB
  539. return
  540. SCANEOF:
  541. cmp [loadmod],0
  542. je sj52
  543. ;----- Load till physical end of file
  544. cmp cx,word ptr[amnt_req]
  545. jb sj51
  546. xor al,al
  547. inc al ;reset zero flag
  548. return
  549. sj51:
  550. jcxz sj51b
  551. push di ;get rid of any ^Z at the end of the file
  552. add di,cx
  553. dec di ;points to last char
  554. cmp byte ptr [di],1ah
  555. pop di
  556. jne sj51b
  557. dec cx
  558. sj51b:
  559. xor al,al ;set zero flag
  560. call check_end ;check that we have a CRLF pair at the end
  561. return
  562. ;----- Load till first ^Z is found
  563. sj52:
  564. PUSH DI
  565. PUSH CX
  566. MOV AL,1AH
  567. or cx,cx
  568. jz not_found ;skip with zero flag set
  569. REPNE SCASB ;Scan for end of file mark
  570. jnz not_found
  571. LAHF ;Save flags momentarily
  572. inc cx ;include the ^Z
  573. SAHF ;Restore flags
  574. not_found:
  575. mov di,cx ;not found at the end
  576. POP CX
  577. LAHF ;Save flags momentarily
  578. SUB CX,DI ;Reduce byte count if EOF found
  579. SAHF ;Restore flags
  580. POP DI
  581. call check_end ;check that we have a CRLF pair at the end
  582. return
  583. ;-----------------------------------------------------------------------
  584. ; If the end of file was found, then check that the last character
  585. ; in the file is a LF. If not put a CRLF pair in.
  586. check_end:
  587. jnz not_end ;end was not reached
  588. pushf ;save return flag
  589. push di ;save pointer to buffer
  590. add di,cx ;points to one past end on text
  591. dec di ;points to last character
  592. cmp di,offset dg:start
  593. je check_no
  594. cmp byte ptr[di],0ah ;is a LF the last character?
  595. je check_done ;yes, exit
  596. check_no:
  597. mov byte ptr[di+1],0dh ;no, put a CR
  598. inc cx ;one more char in text
  599. mov byte ptr[di+2],0ah ;put a LF
  600. inc cx ;another character at the end
  601. check_done:
  602. pop di
  603. popf
  604. not_end:
  605. return
  606. CRLF:
  607. push dx
  608. mov ax,msg_crlf
  609. call display_message
  610. pop dx
  611. return
  612. LF:
  613. mov ax,msg_lf
  614. jmp display_message
  615. ABORTCOM:
  616. MOV AX,CS
  617. MOV DS,AX
  618. MOV ES,AX
  619. MOV AX,cstack
  620. MOV SS,AX
  621. MOV SP,STACK
  622. STI
  623. CALL CRLF
  624. JMP COMMAND
  625. DELBAK:
  626. ;Delete old backup file (.BAK)
  627. MOV BYTE PTR [DELFLG],1
  628. MOV DI,[EXT_PTR]
  629. MOV SI,OFFSET DG:BAK
  630. MOVSW
  631. MOVSW
  632. MOVSB
  633. MOV AH,UNLINK
  634. MOV DX,OFFSET DG:TEMP_PATH
  635. INT 21H
  636. ; $if c ;error ? ;an000; dms;
  637. JNC $$IF1
  638. cmp ax,Access_Denied ;file read only? ;an000; dms;
  639. ; $if e ;yes ;an000; dms;
  640. JNE $$IF2
  641. mov bx,[Wrt_Handle] ;close .$$$ file ;an000; dms;
  642. mov ah,Close ;close function ;an000; dms;
  643. int 21h ;close it ;an000; dms;
  644. mov di,[Ext_Ptr] ;point to extension ;an000; dms;
  645. mov si,offset dg:$$$File ;point to .$$$ extension;an000; dms;
  646. movsw ;get .$$$ extension ;an000; dms;
  647. movsw ; ;an000; dms;
  648. movsb ; ;an000; dms;
  649. mov dx,offset dg:Temp_Path ;point to .$$$ file ;an000; dms;
  650. mov ah,Unlink ;delete it ;an000; dms;
  651. int 21h ; ;an000; dms;
  652. mov di,[Ext_Ptr] ;point to extension ;an000; dms;
  653. mov si,offset dg:BAK ;point to .BAK extension;an000; dms;
  654. movsw ;get .BAK extension ;an000; dms;
  655. movsw ; ;an000; dms;
  656. movsb ; ;an000; dms;
  657. mov dx,offset dg:Del_Bak_Ptr;point to error message ;an000; dms;
  658. jmp Xerror ;display message & exit ;an000; dms;
  659. ; $endif
  660. $$IF2:
  661. ; $endif
  662. $$IF1:
  663. MOV DI,[EXT_PTR]
  664. MOV SI,OFFSET DG:$$$FILE
  665. MOVSW
  666. MOVSW
  667. MOVSB
  668. return
  669. ;-----------------------------------------------------------------------;
  670. ; Will scan buffer given pointed to by SI and get rid of quote
  671. ;characters, compressing the line and adjusting the length at the
  672. ;begining of the line.
  673. ; Preserves al registers except flags and AX .
  674. unquote:
  675. push cx
  676. push di
  677. push si
  678. mov di,si
  679. mov cl,[si-1] ;length of buffer
  680. xor ch,ch
  681. mov al,quote_char
  682. cld
  683. unq_loop:
  684. jcxz unq_done ;no more chars in the buffer, exit
  685. repnz scasb ;search for quote character
  686. jnz unq_done ;none found, exit
  687. push cx ;save chars left in buffer
  688. push di ;save pointer to quoted character
  689. push ax ;save quote character
  690. mov al,byte ptr[di] ;get quoted character
  691. call make_cntrl
  692. mov byte ptr[di],al
  693. pop ax ;restore quote character
  694. mov si,di
  695. dec di ;points to the quote character
  696. inc cx ;include the carriage return also
  697. rep movsb ;compact line
  698. pop di ;now points to after quoted character
  699. pop cx
  700. jcxz sj13 ;if quote char was last of line do not adjust
  701. dec cx ;one less char left in the buffer
  702. sj13: pop si
  703. dec byte ptr[si-1] ;one less character in total buffer count also
  704. push si
  705. jmp short unq_loop
  706. unq_done:
  707. pop si
  708. pop di
  709. pop cx
  710. return
  711. ;-----------------------------------------------------------------------;
  712. ; Convert the character in AL to the corresponding control
  713. ; character. AL has to be between @ and _ to be converted. That is,
  714. ; it has to be a capital letter. All other letters are left unchanged.
  715. make_cntrl:
  716. push ax
  717. and ax,11100000b
  718. cmp ax,01000000b
  719. pop ax
  720. jne sj14
  721. and ax,00011111b
  722. sj14:
  723. return
  724. ;---- Kill spaces in buffer --------------------------------------------;
  725. ;=========================================================================
  726. ; kill_bl : Parses over spaces in a buffer.
  727. ;
  728. ; Date : 6/10/86
  729. ;=========================================================================
  730. kill_bl:
  731. push bx ;an000;save affected reg.
  732. kill_bl_cont:
  733. lodsb ;get rid of blanks
  734. cmp al,9
  735. je kill_bl_cont ;an000;it is a tab
  736. cmp al,10
  737. je kill_bl_cont ;an000;if LF
  738. cmp al,' '
  739. je kill_bl_cont ;an000;we have a space
  740. ifdef DBCS ;an000;is this a kanji assembly
  741. call testkanj ;an000;do we have a dbcs lead byte
  742. ; $if nz ;an000;yes, we have a lead byte
  743. JZ $$IF5
  744. cmp al,DB_SP_HI ;an000;is it DB_SP_HI
  745. ; $if z ;an000;it is DB_SP_HI
  746. JNZ $$IF6
  747. mov bl,ds:[si] ;an000;set up for compare
  748. cmp bl,DB_SP_LO ;an000;is it DB_SP_LO
  749. ; $if z ;an000;we have an asian blank
  750. JNZ $$IF7
  751. lodsb ;an000;skip byte containing 81h
  752. jmp kill_bl_cont
  753. ; $endif ;an000;
  754. $$IF7:
  755. ; $endif ;an000;fall through no delim
  756. $$IF6:
  757. ; found
  758. ; $endif ;an000;end test for dbcs lead byte
  759. $$IF5:
  760. endif ;an000;end conditional assembly
  761. pop bx ;an000;restore affected reg.
  762. return
  763. ;----- Capitalize the character in AL ----------------------------------;
  764. ; ;
  765. ; Input: ;
  766. ; ;
  767. ; AL contains a character to capitalize ;
  768. ; ;
  769. ; Output: ;
  770. ; ;
  771. ; AL contains a capitalized character ;
  772. ; ;
  773. ;-----------------------------------------------------------------------;
  774. MAKE_CAPS:
  775. CMP AL,"a"
  776. JB CAPS1
  777. CMP AL,"z"
  778. ifdef DBCS
  779. JA CAPS1 ; M003 MSKK TAR 476, kana chars
  780. else
  781. JG CAPS1
  782. endif
  783. AND AL,0DFH
  784. CAPS1:
  785. return
  786. QUIT:
  787. CMP ParamCt,1
  788. JZ Quit1
  789. CERR: JMP ComErr
  790. Quit1: CMP Param1,0
  791. JNZ CERR
  792. MOV DX,OFFSET DG:QMES_ptr
  793. call std_printf
  794. IFDEF DBCS
  795. CALL TESTKANJ
  796. JZ ASCII
  797. MOV AX, (STD_CON_INPUT_FLUSH SHL 8) + 0
  798. INT 21H ; Eat the trailing byte.
  799. JMP CRLF
  800. ASCII:
  801. ENDIF
  802. ;=========================================================================
  803. ; We are invoking the VAL_YN proc here. This will replace the
  804. ; method of Y/N validation used prior to DOS 4.00.
  805. ;
  806. ; Date : 6/10/87
  807. ;=========================================================================
  808. call val_yn ;an000;pass Y/N byte in AL to macro
  809. cmp ax,yes ;an000;did we return a Y
  810. jz NoCRLF ;an000; dms; close the file
  811. cmp ax,no ;an000; dms; return N?
  812. ; $if ne ;an000; dms; neither N or Y - reprompt
  813. JE $$IF11
  814. call crlf ; spit out crlf
  815. jmp Quit1 ;an000; dms; reprompt
  816. ; $endif ;an000; dms;
  817. $$IF11:
  818. call crlf ; spit out CRLF
  819. return ;an000; dms;
  820. ;=========================================================================
  821. ; End of Y/N validation check for qmes_ptr
  822. ;=========================================================================
  823. NOCRLF:
  824. MOV BX,[WRT_HANDLE]
  825. MOV AH,CLOSE
  826. INT 21H
  827. MOV DX,OFFSET DG:TEMP_PATH
  828. MOV AH,UNLINK
  829. INT 21H
  830. mov ah,exit
  831. xor al,al
  832. INT 21H
  833. QUERY:
  834. TEST BYTE PTR [QFLG],-1
  835. retz
  836. MOV DX,OFFSET DG:ASK_ptr
  837. call std_printf
  838. PUSH AX
  839. CALL CRLF
  840. POP AX
  841. IFDEF DBCS
  842. CALL TESTKANJ
  843. JZ ASCII1
  844. PUSH AX
  845. MOV AX,(STD_CON_INPUT_FLUSH SHL 8) + 0
  846. INT 21H ;Eat the trailing byte
  847. XOR AX,AX
  848. INC AX ; non zero flag
  849. POP AX
  850. return
  851. ASCII1:
  852. ENDIF
  853. CMP AL,13 ;Carriage return means yes
  854. retz
  855. ;=========================================================================
  856. ; We are invoking the VAL_YN proc here. This will replace the
  857. ; method of Y/N validation used prior to DOS 4.00.
  858. ; This invocation of val_yn will return ZR if Y is found, otherwise
  859. ; it will return NZ.
  860. ;
  861. ; Date : 6/10/87
  862. ;=========================================================================
  863. call val_yn ;an000;pass Y/N byte in AL to macro
  864. cmp ax,yes ;an000;did we return a Y
  865. je Query_Exit ;an000; dms; exit Y/N validation
  866. cmp ax,no ;an000; dms; N response?
  867. jne Query ;an000; dms; no - reprompt user
  868. cmp ax,yes ;an000; dms; must have N response - force
  869. ; NZ flag
  870. Query_Exit:
  871. ;=========================================================================
  872. ; End of Y/N validation check for ask_ptr
  873. ;=========================================================================
  874. return
  875. ;=========================================================================
  876. ; EDLIN_DISP_COUNT: This routine will determine the number of lines
  877. ; actually displayed to the screen. Lines displayed to
  878. ; the screen for one EDLIN line printed will be calculated
  879. ; by the following formula:
  880. ;
  881. ; LINES_PRINTED = (LINE_LEN + 10) / SCREEN_WIDTH
  882. ;
  883. ; LINES_PRINTED - Actual number of lines printed on screen
  884. ; for one EDLIN line. If LINES_PRINTED has
  885. ; a remainder, it will be rounded up.
  886. ;
  887. ; LINE_LEN - The length, in bytes, of the EDLIN line
  888. ; printed.
  889. ;
  890. ; SCREEN_WIDTH - The width in bytes of the current display.
  891. ;
  892. ; Inputs : DI - offset into buffer containing line printed
  893. ; DISP_WIDTH - width of current video output
  894. ;
  895. ; Outputs: LC_ADJ - factor to adjust line counter by
  896. ;
  897. ; Date : 6/10/87
  898. ;=========================================================================
  899. EDLIN_DISP_COUNT proc near ;an000;lines printed
  900. push dx ;an000;save affected regs
  901. push di ;an000;
  902. push ax ;an000;
  903. push bx ;an000;
  904. push cx ;an000;
  905. mov bx,offset dg:arg_buf ;an000;arg_buf holds line
  906. ; printed
  907. mov ax,di ;an000;where print line ends
  908. sub ax,bx ;an000;diff = line's length
  909. add ax,10 ;an000;adjust for leading blks
  910. mov cl,dg:disp_width ;an000;set up for division
  911. div cl ;an000;divide AX by the
  912. ; width of the console
  913. cmp ah,0 ;an000;see if a remainder
  914. ; $if nz ;an000;if a remainder
  915. JZ $$IF13
  916. add al,1 ;an000;increment AL 1
  917. ; to round upward
  918. ; $endif ;an000;
  919. $$IF13:
  920. mov lc_adj,al ;an000;number of lines printed
  921. ; on console
  922. pop cx ;an000;restore affected regs
  923. pop bx ;an000;
  924. pop ax ;an000;
  925. pop di ;an000;
  926. pop dx ;an000;
  927. ret ;an000;return to caller
  928. EDLIN_DISP_COUNT endp ;an000;end proc
  929. ;=========================================================================
  930. ; EDLIN_PG_COUNT : This routine determines whether or not we will continue
  931. ; displaying text lines based on the count of lines that
  932. ; can be output to the current video screen.
  933. ;
  934. ; Inputs : LC_ADJ - adjustment factor for number of lines printed
  935. ; PG_COUNT - number of lines remaining on current video
  936. ; display
  937. ; DX - holds the total number of lines to print
  938. ; CONTINUE - signals if the user wants to continue
  939. ; printing lines.
  940. ;
  941. ; Outputs: LC_FLAG - used to signal completion of print
  942. ;
  943. ; Date : 6/10/87
  944. ;=========================================================================
  945. EDLIN_PG_COUNT proc near ;an000;track remaining lines
  946. push ax ;an000;save affected regs
  947. mov lc_flag,true ;an000;init. flag to signal
  948. ; continue printing
  949. mov al,pg_count ;an000;set up for page adj.
  950. cmp al,lc_adj ;an000;see if we are at end
  951. ; $if be ;an000
  952. JNBE $$IF15
  953. mov pg_count,0 ;an000;set pg_count to 0
  954. ; $else
  955. JMP SHORT $$EN15
  956. $$IF15:
  957. sub al,lc_adj ;an000;adjust number of lines
  958. mov pg_count,al ;an000;save remaining line ct.
  959. ; $endif ;an000;
  960. $$EN15:
  961. dec dx ;an000;decrease total number
  962. ; of lines to print by 1
  963. ; $if nz ;an000;more lines to print
  964. JZ $$IF18
  965. cmp pg_count,0 ;an000;have we printed screen
  966. ; $if be ;an000;we have printed screen
  967. JNBE $$IF19
  968. call EDLIN_PG_PROMPT ;an000;prompt the user to
  969. ; "Continue(Y/N)?"
  970. cmp continue,true ;an000;did user say continue
  971. ; $if z ;an000;continue
  972. JNZ $$IF20
  973. mov al,dg:disp_len ;an000;begin init of screen
  974. ; dec al ;an000; length
  975. mov pg_count,al ;an000;
  976. ; $else ;an000;do not continue
  977. JMP SHORT $$EN20
  978. $$IF20:
  979. mov lc_flag,false ;an000;signal no more to print
  980. ; $endif ;an000;
  981. $$EN20:
  982. ; $endif ;an000;
  983. $$IF19:
  984. ; $else ;an000;total lines printed
  985. JMP SHORT $$EN18
  986. $$IF18:
  987. mov lc_flag,false ;an000;signal no more to print
  988. ; $endif ;an000;
  989. $$EN18:
  990. pop ax ;an000;restore affected regs
  991. ret ;an000;return to caller
  992. EDLIN_PG_COUNT endp ;an000;end procedure
  993. ;=========================================================================
  994. ; EDLIN_PG_PROMPT : This routine prompts the user as to whether or not to
  995. ; continue printing lines to the video display, if lines
  996. ; are still present for printing.
  997. ;
  998. ; Inputs : none
  999. ;
  1000. ; Outputs: CONTINUE - flag that signals other routines whether or
  1001. ; not to continue printing.
  1002. ;
  1003. ; Date : 6/10/87
  1004. ;=========================================================================
  1005. EDLIN_PG_PROMPT proc near ;an000;ask user to continue?
  1006. push dx ;an000;save affected regs.
  1007. push ax ;an000;
  1008. EPP_Reprompt:
  1009. mov dx,offset dg:cont_ptr ;an000;point to Continue msg.
  1010. call std_printf ;an000;invoke message ret.
  1011. push ax ;an000;save affected regs.
  1012. call crlf ;an000;send crlf
  1013. pop ax ;an000;restore affected regs.
  1014. call val_yn ;an000;Y/N validation
  1015. cmp ax,yes ;an000;did we have a Y
  1016. jz EPP_True_Exit ;an000;we had a Y
  1017. cmp ax,no ;an000;did we have a N
  1018. jz EPP_False_Exit ;an000;yes
  1019. jmp EPP_Reprompt ;an000;neither Y or N - reprompt
  1020. EPP_True_Exit:
  1021. mov Continue,True ;an000;flag Y found
  1022. jmp short EPP_Exit ;an000;exit routine
  1023. EPP_False_Exit:
  1024. mov Continue,False ;an000;flag N found
  1025. EPP_Exit:
  1026. pop ax ;an000;restore affected regs.
  1027. pop dx ;an000;
  1028. ret ;an000;return to caller
  1029. EDLIN_PG_PROMPT endp ;an000;end procedure
  1030. ;=========================================================================
  1031. ; val_yn: This proc validates a Y/N response entered by the user. The
  1032. ; routine uses the new functionality of "GET EXTENDED COUNTRY
  1033. ; INFORMATION" being implemented in DOS 4.00.
  1034. ;
  1035. ; Inputs : AL - character to be validated for Y/N response
  1036. ;
  1037. ; Outputs: AX - 00h = "N"o
  1038. ; - 01h = "Y"es
  1039. ;=========================================================================
  1040. val_yn proc near ;an000;validate Y/N response
  1041. push dx ;an000;save affected registers
  1042. push cx ;an000;
  1043. push bx ;an000;
  1044. mov dl,al ;an000;character to be checked for Y/N
  1045. mov ah,GetExtCntry ;an000;get extended country information
  1046. mov al,yn_chk ;an000;perform Y/N checking
  1047. mov cx,max_len ;an000;max. len. of Y/N char.
  1048. int 21h ;an000;invoke function
  1049. pop bx ;an000;restore affected registers
  1050. pop cx ;an000;
  1051. pop dx ;an000;
  1052. ret ;an000;return to caller
  1053. val_yn endp ;an000;end proc
  1054. code ends
  1055. end
  1056.