文字バッファの表現と文書行の管理2016年03月06日 20:30

文字バッファの表現と文書行の管理

編集するテキストは、バッファbuf()にしまい込む。この中には、行と行をリンクさせる 指標も含む。

     buf(k+0)   PREV 前の行の指標
     buf(k+4)   NEXT 次の行の指標
     buf(k+8)   MARK 広域指定の処理に使用
     buf(k+9)   TEXT 文字列の第一文字
     buf(k+10)  ...  第二文字・・・

このバッファを操作するルーチンをは、下記の通り。

     setbuf()  バッファを初期化して、第0行をだけを含む状態にする。
     clrbuf()  作業ファイルを捨てる。現状の版では、何もしない。
     inject(lin) linのテキストをバッファに転写する。
               curlinは、最後に送り込まれた行を指させる。
     getind(n) 行番号nをその行を占める指標に変換する。
     gettxt()  行の内容を共通領域ctxtのtxtに転写する。
     relink(k1,k2,k3,k4) 指標のつなぎ替えを行う。k2の逆方向の指標にk1をささせる。
               k3の順方向の指標にはk4を指させる。

文字バッファbufは共通領域cbufに置かれる。 共通領域cbufのRATFOR版は、以下の通り。

# cbuf.ri
      common /cbuf/buf,lastbf
      character buf(MAXBUF) # buffer for pointers plus text
      integer lastbf        # last element used in buf

WATCOM Fortran77版は以下の通り。

c cbuf.fi
      common /cbuf/buf,lastbf
      integer*1 buf(20000000) ! MAXBUF(20000000) buffer for pointers plus text
      integer lastbf          ! last element used in buf

文字バッファの文書は必要に応じてバッファtxtに転写される。 バッファtxtは共通領域ctxtに置かれる。 共通領域ctxtのRATFOR版は、以下の通り。

# ctxt.ri
      common /ctxt/txt
      character txt(MAXLINE) # text line for matching and output

WATCOM Fortran77版は以下の通り。

c ctxt.fi
      common /ctxt/txt
      integer*1 txt(81)               ! MAXLINE(81) text line for matching and output

setbuf()のRATFOR版は、以下の通り。

# setbuf.r4 (in memory) -- initialize line storage buffer
      subroutine setbuf
      logical addset,junk
      include cbuf.ri
      include clines.ri

      call relink(LINE0,LINE0,LINE0,LINE0)
      lastbf = LINE0 + TEXT
      junk = addset(EOF,buf,lastbf,MAXBUF)
      curln = 0
      lastln = 0
      return
      end

WATCOM Fortran77版は以下の通り。

c setbuf.f (in memory) -- initialize line storage buffer
      subroutine setbuf
      integer addset,junk

      include cbuf.fi
      include clines.fi

      call relink(1,1,1,1)              ! LINE0(1)
      lastbf = 1 + 12                   ! LINE0(1) TEXT(12)
      junk = addset(-2,buf,lastbf,20000000) ! EOS(-2) MAXBUF(20000000)
      curln = 0
      lastln = 0
      return
      end

clrbuf()のRATFOR版は、以下の通り。

# clrbuf.r4 -- initialize for new file
      subroutine clrbuf

      return # nothing to do
      end

WATCOM Fortran77版は以下の通り。

c clrbuf.for -- initialize for new file
      subroutine clrbuf
      return ! nothing to do
      end

getind()のRATFOR版は、以下の通り。getbufptr()は、バッファbufから、integerの 指標を取り出すためのルーチンである。

# getind.r4 -- locate line index in buffer
      integer function getind(line)
      integer line
      integer j,k,getbufptr

      include cbuf.fi

      k = LINE0
      for (j = 0; j < line; j = j + 1)
          k = getbufptr(buf(k+NEXT))
      getind = k
      return
      end

WATCOM Fortran77版は以下の通り。

c getind.f -- locate line index in buffer
      integer function getind(line)
      integer line
      integer j,k,getbufptr

      include cbuf.fi

      k = 1                    ! LINE0(1)
      j = 0
      while (j .lt. line) do
          k = getbufptr(buf(k+4)) ! NEXT(4)
          j = j + 1
      end while
      getind = k
      return
      end

getbufptr()のRATFOR版は、以下の通り。

# getbufptr.r4
      integer function getbufptr(buf)
      integer buf

      getbufptr = buf
      return
      end

WATCOM Fortran77版は以下の通り。

c getbufptr.for
      integer function getbufptr(buf)
      integer buf

      getbufptr = buf
      return
      end

inject()のRATFOR版は、以下の通り。

# inject.f -- put text from line after curln
      integer function inject(lin)
      character lin(MAXLINE)
      integer addset,junk
      integer getind,nextln
      integer i,k1,k2,k3
      include cbuf.ri
      include clines.ri

      for (i = 1; lin(i) != EOS; ) {
          k3 = lastbf
          lastbf = lastbf + TEXT
          while (lin(i) != EOS) {
              junk = addset(lin(i),buf,lastbf,MAXBUF)
              i = i + 1
              if (lin(i-1) == NEWLINE)
                  break
              }
          if (addset(EOS,buf,lastbf,MAXBUF) == NO) {
              inject = ERR
              break
              }
          k1 = getind(curln)
          k2 = getind(nextln(curln))

          call relink(k1,k3,k3,k2)
          call relink(k3,k2,k1,k3)
          curln  = curln + 1
          lastln = lastln  + 1
          inject = OK
          }
      return
      end

WATCOM Fortran77版は以下の通り。

c inject.f -- put text from line after curln
      integer function inject(lin)
      integer*1 lin(*)
      integer addset,junk
      integer getind,nextln
      integer i,k1,k2,k3
      include cbuf.fi
      include clines.fi

      i = 1
      while (lin(i) .ne. -2) do         ! EOS(-2)
          k3 = lastbf
          lastbf = lastbf + 12          ! TEXT(12)
          while (lin(i) .ne. -2) do     ! EOS(-2)
              junk = addset(lin(i),buf,lastbf,20000000) ! MAXBUF(20000000)
              i = i + 1
              if (lin(i-1) .eq. 10) then ! NEWLINE(10)
                  exit
              end if
          end while
          if (addset(-2,buf,lastbf,20000000) .eq. 0) then ! NO(0) MAXBUF(20000000)
              inject = -3               ! ERR(-3)
              exit
          end if
          k1 = getind(curln)
          k2 = getind(nextln(curln))

          call relink(k1,k3,k3,k2)
          call relink(k3,k2,k1,k3)
          curln  = curln + 1
          lastln = lastln  + 1
          inject = -2                   ! OK(-2)
      end while
      return
      end

relink()のRATFOR版は、以下の通り。

# relink.r4 -- rewrite two harf links
      subroutine relink(a,x,y,b)
      integer a,b,x,y

      include cbuf.ri

      call setbufptr(a,buf(x+PREV))
      call setbufptr(b,buf(y+NEXT))
      return
      end

WATCOM Fortran77版は以下の通り。

c relink.f -- rewrite two harf links
      subroutine relink(a,x,y,b)
      integer a,b,x,y

      include cbuf.fi

      call setbufptr(a,buf(x+0))  ! PREV(0)
      call setbufptr(b,buf(y+4))  ! NEXT(4)
      return
      end

ここで、setbufptr()は指標をセットするルーチン。

setbufptr()のRATFOR版は、以下の通り。

# setbufptr.r4
      subroutine setbufptr(ptr,buf)
      integer ptr,buf

      buf = ptr
      return
      end

WATCOM Fortran77版は以下の通り。

c setbufptr.for
      subroutine setbufptr(ptr,buf)
      integer ptr,buf

      buf = ptr
      return
      end

コメント

_ Payoneer 限度額 ― 2016年05月12日 00:11

Ahaa, its good discussion concerning this piece of writing at this place at this
website, I have read all that, so at this time me also
commenting at this place.

_ www.krogerfeedback.com ― 2016年06月05日 19:08

I really like your blog.. very nice colors &amp; theme. Did you create this website yourself or did you hire someone to do it for you?
Plz reply as I&#39;m looking to create my own blog and would like to know where u got this from.
thanks

_ Mincraft ― 2016年07月03日 03:43

hi!,I really like your writing so a lot! share we keep in touch extra
approximately your article on AOL? I need an expert in this house to unravel my problem.
Maybe that&#39;s you! Looking ahead to look you.

_ migre.me ― 2016年07月09日 15:45

What&#39;s up colleagues, how is everything, and what you would like to
say concerning this piece of writing, in my view its truly amazing
in support of me.

_ www.krogerfeedback.com ― 2016年07月14日 20:36

Touche. Solid arguments. Keep up the good spirit.

_ www.krogerfeedback.com ― 2016年07月26日 05:06

Thanks for sharing your thoughts on www.krogerfeedback.com. Regards

_ kroger digital coupons ― 2016年07月28日 17:35

I&#39;m gone to say to my little brother, that he should also visit this webpage on regular basis to obtain updated from hottest gossip.

_ Mincraft ― 2016年08月12日 15:33

It is not my first time to go to see this web site, i am visiting
this web site dailly and take pleasant facts from here daily.

_ fix connections to bluetooth audio devices and wireless displays in windows 10 ― 2016年08月19日 06:42

I every time used to read paragraph in news papers but now as I am a
user of web therefore from now I am using net for posts,
thanks to web.

_ quest bars ― 2016年09月09日 05:07

If you want to get a good deal from this paragraph
then you have to apply such strategies to your won weblog.

_ ShoeLifts ― 2016年09月11日 05:52

Rattling fantastic info can be found on website.

_ Windows 10 Free Upgrade ― 2016年09月14日 18:03

Fastidious answers in return of this matter with firm
arguments and telling everything on the topic of that.

_ south chicago healthcare ― 2016年09月22日 15:24

Hey there superb website! Does running a blog such as this take
a lot of work? I&#39;ve virtually no expertise in programming but I had been hoping to start
my own blog in the near future. Anyway, should you have any ideas or techniques for new blog
owners please share. I know this is off subject however I just needed to ask.

Thanks!

_ quest bars ― 2016年09月24日 16:47

WOW just what I was searching for. Came here by searching for quest bars

_ minecraft awesome and sweet ― 2016年10月02日 03:15

Great article.

_ minecraft sweet and awesome lucky block ― 2016年10月02日 22:15

It&#39;s awesome for me to have a web site, which is beneficial in support of my experience.
thanks admin

_ plenty of fish dating site of free dating ― 2016年10月05日 11:00

Hi there, just became aware of your blog through Google, and found that it is truly informative.
I am gonna watch out for brussels. I will be grateful if you continue this in future.
Numerous people will be benefited from your writing. Cheers!

_ quest bars ― 2016年10月06日 03:43

Hi, i believe that i noticed you visited my site thus i got here to return the choose?.I&#39;m trying
to in finding things to enhance my site!I assume its ok
to make use of some of your ideas!!

_ descargar minecraft 1.7.2 para pc ― 2016年10月10日 04:30

What a stuff of un-ambiguity and preserveness
of valuable familiarity concerning unexpected emotions.

_ como descargar minecraft 1.9 ― 2016年10月13日 02:19

I needed to thank you for this wonderful read!! I certainly loved every
bit of it. I have got you book marked to check out new stuff
you post…

_ como descargar minecraft ― 2016年10月14日 10:47

I’m not that much of a internet reader to be honest but your blogs really
nice, keep it up! I&#39;ll go ahead and bookmark your website to come
back later on. Cheers

_ gamefly 3 month free trial ― 2016年11月15日 22:08

Hello, its pleasant paragraph concerning media print, we all know media is a wonderful source of information. Gamefly 3 month free trial

_ who carries quest bars ― 2016年11月20日 02:19

We stumbled over here by a different website and thought I might as
well check things out. I like what I see so i am just following you.
Look forward to looking over your web page for a second time.

_ j.mp ― 2016年12月01日 20:04

Hello! I could have sworn I&#39;ve been to this web site before but after looking at
a few of the posts I realized it&#39;s new to me. Regardless, I&#39;m certainly delighted I discovered it and
I&#39;ll be bookmarking it and checking back often!

_ free dating sites no fees ― 2016年12月10日 12:32

I&#39;ll immediately seize your rss as I can&#39;t in finding your email subscription hyperlink or newsletter service.
Do you have any? Kindly let me realize so that I may just
subscribe. Thanks.

_ Gamefly Free Trial ― 2016年12月18日 11:08

Hi there! This is kind of off topic but I need some
guidance from an established blog. Is it difficult to set
up your own blog? I&#39;m not very techincal but I can figure things out pretty quick.
I&#39;m thinking about creating my own but I&#39;m not sure where to start.
Do you have any tips or suggestions? Appreciate it

_ Gamefly ― 2016年12月18日 19:33

I have been exploring for a bit for any high quality
articles or blog posts on this sort of space .
Exploring in Yahoo I ultimately stumbled upon this site.
Studying this info So i am satisfied to convey that
I&#39;ve an incredibly just right uncanny feeling I found out exactly what I needed.
I such a lot indisputably will make sure to don?t put out
of your mind this web site and provides it a look regularly.

_ Gamefly ― 2016年12月21日 06:40

Howdy! This is kind of off topic but I need some guidance from
an established blog. Is it tough to set up your own blog?
I&#39;m not very techincal but I can figure things out pretty quick.
I&#39;m thinking about making my own but I&#39;m not
sure where to begin. Do you have any points or suggestions?
With thanks

_ www.krogerfeedback.com ― 2016年12月25日 06:29

This website certainly has all of the info I needed about this subject and didn&#39;t know
who to ask.

_ www.krogerfeedback.com ― 2016年12月25日 08:27

Heya this is somewhat of off topic but I was wanting to know if blogs use WYSIWYG editors or if you
have to manually code with HTML. I&#39;m starting a blog soon but have no
coding skills so I wanted to get advice from someone with experience.
Any help would be greatly appreciated!

_ www.krogerfeedback.com ― 2016年12月26日 01:50

Sweet blog! I found it while surfing around on Yahoo
News. Do you have any tips on how to get listed in Yahoo News?
I&#39;ve been trying for a while but I never seem to get there!
Appreciate it

_ www.krogerfeedback.com ― 2016年12月26日 03:35

Appreciating the commitment you put into your blog and in depth information you
provide. It&#39;s nice to come across a blog every once in a while that isn&#39;t the same out
of date rehashed material. Wonderful read! I&#39;ve saved your
site and I&#39;m including your RSS feeds to my Google account.

_ match.com reviews 2017 ― 2017年01月04日 00:55

Hi there every one, here every one is sharing such know-how, thus it&#39;s good to read this weblog, and I used to visit this weblog everyday.

_ free dating sites no fees ― 2017年01月06日 19:09

We absolutely love your blog and find the majority of your post&#39;s to be exactly what I&#39;m looking for.
can you offer guest writers to write content in your case?
I wouldn&#39;t mind composing a post or elaborating on many of the subjects you write concerning here.
Again, awesome website!

_ absolutely free dating sites ― 2017年01月07日 19:24

Hi to all, how is all, I think every one is getting
more from this site, and your views are fastidious in favor of
new users.

_ absolutely free dating sites ― 2017年01月08日 15:56

Everything is very open with a very clear explanation of
the issues. It was definitely informative. Your site is useful.
Many thanks for sharing!

_ quest bars canada cheapest ― 2017年01月10日 09:15

Keep on working, great job!

_ gamefly free trial ― 2017年01月11日 14:29

I have to thank you for the efforts you&#39;ve put in penning this blog.
I really hope to see the same high-grade blog posts from you later on as well.
In fact, your creative writing abilities has motivated me to get my own, personal
blog now ;)

_ www.krogerfeedback.com ― 2017年01月12日 00:16

Very nice post. I just stumbled upon your
weblog and wished to say that I have truly enjoyed surfing around your blog posts.
In any case I will be subscribing to your rss feed and I hope
you write again soon!

_ www.krogerfeedback.com ― 2017年01月13日 07:08

Hi there! This post could not be written any better!
Looking at this post reminds me of my previous roommate!
He continually kept preaching about this. I am going to forward this post to him.

Pretty sure he&#39;s going to have a great read.
Thanks for sharing!

_ www.krogerfeedback.com ― 2017年01月14日 03:00

Hey there! I just wanted to ask if you ever have any problems with hackers?
My last blog (wordpress) was hacked and I ended up losing a few months of hard work due to no backup.
Do you have any solutions to prevent hackers?

_ www.krogerfeedback.com ― 2017年01月14日 12:24

Attractive portion of content. I simply stumbled upon your weblog and in accession capital to claim that I acquire in fact loved account your blog posts.
Anyway I will be subscribing for your augment or even I success you get entry
to consistently rapidly.

_ www.krogerfeedback.com ― 2017年01月15日 06:49

Having read this I believed it was extremely enlightening.
I appreciate you taking the time and energy to put
this content together. I once again find myself spending a significant amount of time both reading
and posting comments. But so what, it was still worthwhile!

_ www.krogerfeedback.com ― 2017年01月21日 04:45

Magnificent items from you, man. I have be mindful your stuff prior to and
you are simply extremely fantastic. I actually like what you have
obtained here, really like what you are stating and the way during which you say it.

You&#39;re making it enjoyable and you still care for to stay it smart.

I can&#39;t wait to read far more from you. That is actually
a tremendous web site.

_ take a look at the www.krogerfeedback.com webpage ― 2017年01月27日 14:56

Howdy! I could have sworn I&#39;ve been to this website before but
after checking through some of the post I realized
it&#39;s new to me. Anyways, I&#39;m definitely glad I found it and I&#39;ll be bookmarking and checking back often!

_ http://wisewomensport.com/ ― 2017年01月28日 08:52

Thank you for the good writeup. It in fact was a
amusement account it. Look advanced to far
added agreeable from you! However, how could we communicate?

_ http://tinyurl.com/jz2m2g8 ― 2017年01月29日 10:04

Valuable information. Lucky me I discovered your website unintentionally, and
I am shocked why this twist of fate did not happened in advance!
I bookmarked it.

_ g ― 2017年01月30日 13:22

I&#39;ve been exploring for a bit for any high quality articles or weblog posts in this
sort of house . Exploring in Yahoo I finally
stumbled upon this site. Reading this info So i am happy to show that I&#39;ve
an incredibly good uncanny feeling I came upon just what I needed.
I so much without a doubt will make sure to
don?t forget this web site and provides it a glance on a constant basis.

_ match.com ― 2017年01月31日 01:21

Just wish to say your article is as surprising. The clarity in your post is simply nice and i could assume you are an expert on this
subject. Well with your permission let me to grab your feed to keep up to date with forthcoming post.
Thanks a million and please carry on the gratifying work.

_ match.com ― 2017年01月31日 04:25

An outstanding share! I have just forwarded this onto a coworker
who has been doing a little homework on this. And he actually ordered me breakfast because I discovered it for him...
lol. So allow me to reword this.... Thank YOU for the
meal!! But yeah, thanx for spending the time to discuss this topic
here on your web page.

※コメントの受付件数を超えているため、この記事にコメントすることができません。

トラックバック

このエントリのトラックバックURL: http://kida.asablo.jp/blog/2016/03/06/8040800/tb