タブの処理、detab,entab2014年11月03日 17:29

これまでに説明していないプログラムについて、2,3回に分けて説明します。

まずは、detabとentab。

detabは、文字列中にタブが現れると空白に置き換えます。entabはこの逆で、 続く空白をタブで置き換えます。

detabは、下記の通り。

# detab.for -- convert tabs to equivalent of blanks
      character getc
      character c
      integer tabpos
      integer col, tabs(MAXLINE)

      call settab(tabs) # set initial tab stops
      col = 1
      while (getc(c) != EOF)
          if (c == TAB)
              repeat {
                   call putc(BLANK)
                   col = col + 1
                   } until (tabpos(col,tabs) == YES)
          else if (c == NEWLINE) {
              call putc(NEWLINE)
              col = 1
              }
          else {
              call pudc(c)
              col = col + 1
              }
      stop
      end

settab()は、tabs配列に、タブ位置情報を作り出します。tabpos()は、現在タブ位置にあるか否かを判定します。 いずれも簡単なルーチンですが、くくり出すことでプログラムの見通しを良くするとともに、タブ位置情報の構造を隠蔽することに 役立っています。

settab()は以下の通り。

# settab.r4 -- set initial tab stops
      subroutine settab(tabs)
      integer mod
      integer i, tabs(MAXLINE)

      for (i = 1; i <= MAXLINE; i = i + 1)
          if (mod(i,8) == 1)
              tabs(i) = YES
          else
              tabs(i) = NO
      return
      end

tabpos()は以下の通り。

# tabpos.r4 -- return YES(.true.) if col is a tab stop
      integer function tabpos(col,tabs)
      integer col, tabs(MAXLINE)

      if (col > MAXLINE)
          tabpos = YES
      else
          tabpos = tabs(col)
      return
      end

detab,settab(),tabpos()のWatcom Fortran77版は、下記の通り。

c detab.for -- convert tabs to equivalent of blanks
      program detab
      integer*1 getc,c
      integer col,tabpos,tabs(81)       ! MAXLINE(81)

      call settab(tabs) ! set initial tab stops
      col = 1
      while (getc(c) .ne. -1) do        ! EOF(-1)
          if (c .eq. 9) then            ! TAB(9)
              loop
                  call putc(32)         ! BLANK(32)
                  col = col + 1
              until (tabpos(col,tabs) .eq. 1) ! YES(1)
          else if (c .eq. 10) then      ! NEWLINE(10)
              call putc(10)             ! NEWLINE(10)
              col = 1
          else
              call putc(c)
              col = col + 1
          endif
      end while
      stop
      end
c settab.for -- set initial tab stops
      subroutine settab(tabs)
      integer i,mod,tabs(81)            ! MAXLINE(81)

      i = 1
      while (i .le. 81) do              ! MAXLINE(81)
          if (mod(i,8) .eq. 1) then
              tabs(i) = 1               ! YES(1)
          else
              tabs(i) = 0               ! NO(0)
          endif
          i = i + 1
      end while
      return
      end
c tabpos.for -- return YES(1) if col is a tab stop
      integer function tabpos(col,tabs)
      integer col,tabs(81)              ! MAXLINE(81)

      if (col .gt. 81) then             ! MAXLINE(81)
          tabpos = 1                    ! YES(1)
      else
          tabpos = tabs(col)
      endif
      return
      end

entabは、下記の通り。

# entab -- replace blanks by tab and blanks
      character getc,c
      integer col,newcol,tabpos,tabs(MAXLINE)

      call settab(tabs)
      cal = 1
      repeat {
          newcol = col
          while (getc(c) == BLANK) { # collect blanks
              newcol = newcol + 1
              if (tabpos(col,tabs) == YES) {
                  call putc(TAB)
                  cal = newcol
                  }
              }
          for ( ; col < newcol; col = col + 1)
              call putc(BLANK)       # output leftover blanks
          if (c == EOF)
              break
          call putc(c)
          if (c == NEWLINE)
              col = 1
          else
              col = col + 1
          }
      stop
      end

ここでも、settab()、tabpos()を使用して、タブ位置情報の構造をを隠蔽しています。

entabのWatcom Fortran77版は、下記の通り。

c entab -- replace blanks by tabs and blanks
      program entab
      integer*1 getc,c
      logical tabpos, tabs(81)          ! MAXLINE(81)
      integer col, newcol

      call settab(tabs)
      col = 1
      loop
          newcol = col
          while (getc(c) .eq. 32) do    ! collect blanks BLANK(32)
              newcol = newcol + 1
              if (tabpos(newcol,tabs)) then
                  call putc(9)          ! TAB(9)
                  col = newcol
              endif
          end while
          while (col .lt. newcol) do    ! output leftover blanks
              call putc(32)             ! BLANK(32)
              col = col + 1
          end while
          if (c .eq. -1) then           ! EOF(-1)
              exit
          endif
          call putc(c)
          if (c .eq. 10) then           ! NEWLINE(10)
              col = 1
          else
              col = col + 1
          endif
      end loop
      stop
      end

コメント

_ Pof Site De Rencontre Gratuite ― 2015年10月18日 12:45

Generally I do not learn post on blogs, but I wish to say that this write-up very compelled me to check out and do so! Your writing taste has been amazed me. Thanks, very nice article.

_ Quest Bar Nutrition Cookie Dough ― 2015年10月19日 00:22

Great blog here! Also your web site loads up very fast! What web host are you using? Can I get your affiliate link to your host? I wish my site loaded up as fast as yours lol

_ forskolin belly buster ― 2015年11月04日 11:57

It&#39;s very straightforward to find out any topic on web as compared to
textbooks, as I found this article at this web page.

_ plenty Of fish dating site Of free dating ― 2015年11月06日 08:51

you are in point of fact a excellent webmaster. The
web site loading speed is amazing. It sort of feels that you&#39;re doing any unique trick.

Also, The contents are masterpiece. you have done a great
task in this topic!

_ plenty of fish dating site of Free dating ― 2015年11月07日 08:32

You could definitely see your skills within the article you
write. The sector hopes for more passionate writers like
you who are not afraid to mention how they believe.
At all times go after your heart.

_ match.com free trial ― 2015年11月08日 17:30

I&#39;ve been browsing online greater than 3 hours these days, but I never found any interesting article like
yours. It is pretty price sufficient for me.
In my view, if all web owners and bloggers made excellent content material as you did, the internet can be
much more useful than ever before.

_ Justin bieber Dating ― 2015年11月08日 22:08

After I initially commented I seem to have clicked on the -Notify
me when new comments are added- checkbox and now each time a comment is added I get 4 emails with the exact same comment.
Perhaps there is a way you are able to remove me from that
service? Kudos!

_ www.krogerfeedback.com ― 2015年11月11日 22:25

This article will assist the internet viewers for setting
up new webpage or even a blog from start to end.

_ kroger krazy coupons printable ― 2015年11月12日 11:31

Hi there every one, here every person is sharing these familiarity,
so it&#39;s good to read this weblog, and I used to visit this webpage every day.

_ kroger printable coupons ― 2015年11月15日 18:46

Attractive section of content. I simply stumbled
upon your weblog and in accession capital to say that I get in fact loved account your weblog posts.
Any way I will be subscribing to your augment and even I success you access persistently quickly.

_ kroger printable coupons ― 2015年11月17日 13:10

Can I simply say what a relief to find somebody that
genuinely knows what they&#39;re talking about on the net. You actually know how to bring an issue to light and make it
important. More people ought to check this out and understand this side of
your story. I was surprised you aren&#39;t more popular given that you certainly have the gift.

_ krogerfeedback.com ― 2015年12月09日 00:48

I&#39;d like to find out more? I&#39;d want to find out some additional information.

_ krogerfeedback.Com ― 2015年12月10日 11:44

This design is wicked! You certainly know how to keep a reader amused.
Between your wit and your videos, I was almost
moved to start my own blog (well, almost...HaHa!) Wonderful job.
I really loved what you had to say, and more than that,
how you presented it. Too cool!

_ quest bars ― 2016年02月09日 01:36

I am really enjoying the theme/design of your site.
Do you ever run into any browser compatibility issues?
A number of my blog visitors have complained about my blog not working correctly in Explorer but looks great in Safari.
Do you have any tips to help fix this issue?

_ quest bars ― 2016年02月09日 15:59

Hi to all, it&#39;s in fact a nice for me to go to see this web
site, it consists of priceless Information.

_ quest bars ― 2016年02月19日 13:42

Hello! This is kind of off topic but I need some advice 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
fast. I&#39;m thinking about setting up my own but I&#39;m not sure where to begin. Do you have any
ideas or suggestions? Thank you

_ bernie sanders ― 2016年03月31日 17:57

Everything is very open with a precise explanation of the challenges.
It was really informative. Your site is useful. Thank you for sharing!

_ bernie sanders ― 2016年04月01日 21:03

My brother suggested I might like this web site. He was totally right.

This post truly made my day. You can not imagine just how much time I
had spent for this information! Thanks!

_ walmart credit Card login ― 2016年05月26日 04:25

If you want to get much from this article then you have
to apply such methods to your won web site.

_ walmart credit card login ― 2016年05月26日 04:52

Great post. I was checking constantly this blog and I&#39;m impressed!
Extremely useful information specially the last part :
) I care for such info a lot. I was looking for this certain info for a
long time. Thank you and good luck.

_ www.krogerfeedback.com ― 2016年06月05日 23:20

I&#39;m impressed, I must say. Rarely do I encounter a blog that&#39;s equally educative and engaging, and let me tell you, you&#39;ve hit the nail on the head.
The problem is something too few men and women are speaking intelligently about.
I am very happy that I found this in my search
for something concerning this.

_ Mincraft ― 2016年07月03日 05:21

Thank you for another fantastic post. Where else may
just anybody get that kind of info in such a perfect method of writing?
I have a presentation next week, and I am on the
look for such info.

_ http://j.mp ― 2016年07月09日 14:20

This is the perfect webpage for everyone who hopes to understand this topic.

You realize a whole lot its almost hard to argue with you (not
that I personally would want to…HaHa). You definitely put a brand new spin on a subject which has been written about for a long time.
Excellent stuff, just wonderful!

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

It is appropriate time to make some plans for the long run and it&#39;s time to be happy.

I&#39;ve read this put up and if I may I want to recommend you few interesting things
or tips. Maybe you can write subsequent articles referring to this article.
I desire to learn even more things approximately it!

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

My brother suggested I might like this web site. He was entirely
right. This post actually made my day. You can not consider simply how so much time I had spent for this information! Thanks!

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

Way cool! Some extremely valid points! I appreciate you writing this article and also the rest
of the website is very good.

_ www.krogerfeedback.com ― 2016年07月30日 17:50

Howdy are using Wordpress for your site platform?
I&#39;m new to the blog world but I&#39;m trying to get started and create my
own. Do you require any coding expertise to make your own blog?
Any help would be greatly appreciated!

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

Good replies in return of this matter with solid arguments and describing the
whole thing regarding that.

_ plenty of fish dating site of free dating ― 2016年09月08日 11:05

Hello there I am so excited I found your blog page, I really found you by
error, while I was searching on Yahoo for something else, Anyhow I am
here now and would just like to say thanks
a lot for a remarkable post and a all round exciting blog (I
also love the theme/design), I don’t have time to look over
it all at the moment but I have book-marked it and also added
your RSS feeds, so when I have time I will be back to read a lot more, Please
do keep up the awesome b.

_ quest bars ― 2016年09月09日 19:10

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

_ HeelLifts ― 2016年09月11日 10:09

Very interesting points you have mentioned, thanks for posting.

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

I think the admin of this web page is truly working hard in support of his web
site, as here every stuff is quality based information.

_ heel glass ― 2016年09月22日 16:08

Hi there terrific blog! Does running a blog similar to this take a large amount of
work? I&#39;ve no knowledge of programming but I had
been hoping to start my own blog in the near future.
Anyways, if you have any recommendations or techniques for new blog owners please share.

I know this is off topic but I simply had to ask. Appreciate it!

_ quest bars ― 2016年09月25日 10:24

Hey There. I found your blog using msn. This is
an extremely well written article. I will be sure to bookmark
it and return to read more of your useful information. Thanks for the
post. I will certainly return.

_ sweet and awesome minecraft ― 2016年10月01日 15:21

I visited multiple websites however the audio quality for
audio songs present at this site is actually fabulous.

_ plenty of fish dating site of free dating ― 2016年10月04日 19:09

I was suggested this blog by my cousin. I am not sure whether this post is written by him as no one else know such detailed
about my difficulty. You&#39;re incredible! Thanks!

_ minecraft ― 2016年10月11日 09:22

Excellent blog you have got here.. It&#39;s difficult to
find excellent writing like yours these days.

I really appreciate individuals like you! Take care!!

_ minecraft ― 2016年10月13日 05:21

Way cool! Some extremely valid points! I appreciate you writing this article and
also the rest of the website is very good.

_ juega german minecraft ― 2016年10月15日 08:16

Appreciate the recommendation. Let me try it out.

_ gamefly 3 month free trial ― 2016年11月16日 00:48

Have you ever thought about writing an e-book or guest authoring on other sites?
I have a blog based on the same information you discuss and would really like to have you share
some stories/information. I know my subscribers would value your work.

If you are even remotely interested, feel free to send me an e
mail. Gamefly 3 month free trial

_ gamefly 3 month free trial ― 2016年11月16日 09:55

For most recent news you have to visit web
and on web I found this web site as a most excellent web site for hottest updates.
Gamefly 3 month free trial

_ quest bar ideas ― 2016年11月20日 04:33

This paragraph will assist the internet users for setting up new weblog or even a blog from start to end.

_ http://tinyurl.com ― 2016年12月01日 22:25

Magnificent site. Lots of useful information here. I am sending it to some pals ans additionally sharing in delicious.
And of course, thanks for your effort!

_ t.co ― 2016年12月02日 08:16

Heya i&#39;m for the first time here. I found this board
and I find It really useful &amp; it helped me out much.
I hope to give something back and aid others like you aided me.

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

That is really fascinating, You are an overly professional blogger.
I have joined your rss feed and sit up for looking for extra of your excellent post.
Additionally, I&#39;ve shared your web site in my social networks

_ Gamefly Free Trial ― 2016年12月18日 13:09

If some one wants expert view on the topic of running a blog after that i propose
him/her to pay a quick visit this weblog, Keep up the fastidious work.

_ Gamefly Free Trial ― 2016年12月19日 02:07

Hi there! 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.
Anyhow, I&#39;m definitely glad I found it and I&#39;ll be book-marking and
checking back often!

_ www.krogerfeedback.com ― 2016年12月24日 18:32

I just couldn&#39;t go away your site prior to suggesting that I actually loved
the standard information an individual provide to your visitors?
Is gonna be back steadily to investigate cross-check new posts

_ www.krogerfeedback.com ― 2016年12月25日 00:55

Hi there, I check your new stuff regularly. Your story-telling style is witty, keep it up!

_ www.krogerfeedback.com ― 2016年12月25日 23:51

What&#39;s Happening i am new to this, I stumbled upon this
I&#39;ve found It absolutely useful and it has helped me out loads.
I&#39;m hoping to give a contribution &amp; aid other customers like
its helped me. Good job.

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

トラックバック

このエントリのトラックバックURL: http://kida.asablo.jp/blog/2014/11/03/7481940/tb